File:Polyreg scheffe uk.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(SVG file, nominally 540 × 360 pixels, file size: 38 KB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary[edit]

Description
English: Plot of a cubic polynomial fit using multiple least squares to a simulated data set. Along with the point estimate, a 95% simultaneous confidence band constructed using Scheffe's method is shown. Labelled in Ukrainian.
Українська: Графік допасування до імітованих даних кубічного многочлену із застосуванням декількох найменших квадратів. Разом із точковою оцінкою показано одночасно 95 %-ву довірчу смугу, побудовану із застосуванням методу Шефе.
Date
Source
Author
Other versions

[edit]

SVG development
InfoField
 
The SVG code is valid.
 
This plot was created with Matplotlib.
 
The file size of this SVG plot may be irrationally large because its text has been converted to paths inhibiting translations.
Source code
InfoField

Python code

import numpy as np
import matplotlib.pyplot as plt
import scipy.special as sp

## Розмір вибірки.
n = 100

## Значення предиктора.
XV = np.random.uniform(low=-4, high=4, size=n)
XV.sort()

## Матриця плану.
X = np.ones((n,4))
X[:,1] = XV
X[:,2] = XV**2
X[:,3] = XV**3

## Істинні коефіцієнти.
beta = np.array([0, 0.1, -0.25, -0.25], dtype=np.float64)

## Істинні значення відгуку.
EY = np.dot(X, beta)

## Спостережувані значення відгуку.
Y = EY + np.random.normal(size=n)*np.sqrt(20)

## Отримати оцінки коефіцієнтів.
u,s,vt = np.linalg.svd(X,0)
v = np.transpose(vt)
bhat = np.dot(v, np.dot(np.transpose(u), Y)/s)

## Допасовані значення.
Yhat = np.dot(X, bhat)

## СКП та КСКП.
MSE = ((Y-EY)**2).sum()/(n-X.shape[1])
s = np.sqrt(MSE)

## Ці множники використовуються в побудові інтервалу Шефе.
XtX = np.dot(np.transpose(X), X)
V = [np.dot(X[i,:], np.linalg.solve(XtX, X[i,:])) for i in range(n)]
V = np.array(V)

## F-квантиль, що використовується в побудові інтервалу Шефе.
QF = sp.fdtri(X.shape[1], n-X.shape[1], 0.95)

## Нижня та верхня межі довірчої смуги.
D = s*np.sqrt(X.shape[1]*QF*V)
LB,UB = Yhat-D,Yhat+D

## Створити графік.
plt.clf()
plt.plot(XV, Y, 'o', ms=3, color='grey')
plt.plot(XV, EY, '-', color='blue', label = "Істина")
plt.plot(XV, Yhat, '-', color='green', label = "Оцінка")
plt.plot(XV, LB, '-', color='red', label = "ДС")
plt.plot(XV, UB, '-', color='red')
plt.legend(frameon=False)
plt.ylim([-25,20])
plt.gca().set_yticks([-20,-10,0,10,20])
plt.xlim([-4,4])
plt.gca().set_xticks([-4,-2,0,2,4])
plt.xlabel("X")
plt.ylabel("Y")
plt.savefig("polyreg_scheffe_uk.pdf")
plt.savefig("polyreg_scheffe_uk.svg")

Licensing[edit]

w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current15:41, 8 March 2021Thumbnail for version as of 15:41, 8 March 2021540 × 360 (38 KB)Olexa Riznyk (talk | contribs)Uploaded a work by * File:Polyreg scheffe.svg: {{ut|Skbkekas}} * derivative work: {{Ut|Olexa Riznyk}} from * File:Polyreg scheffe.svg with UploadWizard

File usage on other wikis

The following other wikis use this file:

Metadata