{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HTExample

# HTExample - #Example 1#=========#Code x1=c(0.5,1,1,1.5...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #Example 1 #========= #Code x1=c(0.5,1,1,1.5) x2=c(0.5,0.5,1,1,1,1.5,1.5) y=c(10,12,15,16,9,10,11,12,15,16,20) X=cbind(rep(1,11),c(x1,rep(0,7)),c(rep( 0,4),x2)) model = lm(y~X) summary(model) library(MASS) ginv(t(X)%*%X) #Output > x1=c(0.5,1,1,1.5) > x2=c(0.5,0.5,1,1,1,1.5,1.5) > y=c(10,12,15,16,9,10,11,12,15,16,20) > X=cbind(rep(1,11),c(x1,rep(0,7)),c(rep( 0,4),x2)) > model = lm(y~X) > summary(model) Coefficients: (1 not defined because of singularities) Estimate Std. Error t value Pr(>|t|) (Intercept) 5.616 1.561 3.598 0.00701 ** X1 NA NA NA NA X2 7.453 1.625 4.587 0.00179 ** X3 7.774 1.506 5.163 0.00086 ***--- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.793 on 8 degrees of freedom Multiple R-squared: 0.7748, Adjusted R-squared: 0.7184 F-statistic: 13.76 on 2 and 8 DF, p-value: 0.002574 > library(MASS) > ginv(t(X)%*%X) [,1] [,2] [,3] [1,] 0.7578947 -0.6736842 -0.6631579 [2,] -0.6736842 0.8210526 0.5894737 [3,] -0.6631579 0.5894737 0.7052632 #Example 2...
View Full Document

{[ snackBarMessage ]}

### Page1 / 5

HTExample - #Example 1#=========#Code x1=c(0.5,1,1,1.5...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online