Theophano Mitsa

> library(plspm) > data(mobile) #Let’s take a look at our data > head(mobile) ima1 1

66.67

44.44

2 100.00 3

ima2

ima3

44.44

ima4

44.44

88.89 100.00 100.00

77.78

66.67

55.56

33.33

33.33

44.44 100.00

5 100.00 100.00

44.44

77.78

88.89 100.00

qua4 1

qua5

66.67 55.56

77.78

qua6 44.44

66.67

77.78

88.89 100.00

11.11

val1 22.22

exp2

exp3

qua1

55.56

66.67

55.56

66.67

88.89 100.00

66.67

66.67 100.00

88.89

qua7

44.44

66.67

66.67

44.44

77.78

exp1

88.89 100.00 100.00

4 100.00 100.00

6

ima5

66.67

44.44

val2

66.67

55.56

2 100.00 88.89 100.00 100.00 100.00 100.00 100.00 100.00

66.67

66.67 77.78

66.67

66.67

66.67

66.67

4

77.78 33.33

44.44

77.78

44.44

44.44 100.00 100.00 100.00

88.89

77.78

6 100.00 77.78

88.89

88.89 100.00 100.00

loy2 1 44.44

55.56

55.56 100.00 77.78

66.67

77.78 66.67

loy3 55.56

2 11.11 100.00 3 11.11

66.67

4 33.33 100.00 5 22.22

77.78

6 22.22 100.00

#Let us now create a training and a testing set. > index<-1:nrow(mobile) > set.seed(123)

44.44

77.78

sat3

88.89 comp

66.67

55.56

77.78 100.00 100.00

3

5 100.00 88.89

77.78

88.89

88.89 100.00

sat2

33.33

77.78

77.78 100.00 100.00

66.67

sat1

33.33

88.89 100.00

66.67 100.00 100.00 88.89

qua2

66.67

77.78 66.67

55.56

55.56

44.44 100.00 44.44 100.00 77.78 100.00

loy1

qua3

Theophano Mitsa > testindex<-sample(index,trunc(length(index)/3)) > testset<-mobile[testindex,] > trainset<-mobile[-testindex,] # Now we will create the response variable for the training set, as the average of the 5 image variables. > h1<-nrow(trainset) > trainimean<-numeric(h1) > for(i in 1:h1) { +trainimean[i]<-(trainset$ima1[i]+trainset$ima2[i]+trainset$ima3[i]+trainset$ima4[i]+trainset$ima5[i])/ 5 +} #Let us now remove, from the training set, the columns that correspond to the five components of the latent variable image. > trainset1<-trainset[-c(1:5)]

# Now we will create the response variable for the testing set, as the average of the 5 image variables. > h1<-nrow(testset) > testimean<-numeric(h1) > for(i in 1:h1) { +

testimean[i]<-(testset$ima1[i]+testset$ima2[i]+testset$ima3[i]+testset$ima4[i]+testset$ima5[i])/5

+} #Let us now remove, from the testing set, the columns that correspond to the five components of the latent variable image. > testset1<-testset[-c(1:5)] #As a benchmark, let us compute a model based on linear regression. > modelm<-lm(trainimean~.,data=trainset1) #Let us take a look at the coefficients of the linear regression and their significance. > summary(modelm) ………………………

Theophano Mitsa Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept)

6.519889

4.633504

1.407 0.161503

exp1

-0.043918

0.039415

-1.114 0.266991

exp2

0.142802

0.038630

3.697 0.000308 ***

exp3

0.051840

0.033601

1.543 0.125032

qua1

0.063068

0.069035

0.914 0.362438

qua2

-0.003949

0.039747

-0.099 0.920984

qua3

-0.016342

0.048095

-0.340 0.734508

qua4

0.012258

0.056228

0.218 0.827728

qua5

0.126600

0.055636

2.275 0.024322 *

qua6

0.153209

0.050627

3.026 0.002924 **

qua7

-0.025878

0.049054

-0.528 0.598610

val1

-0.011279

0.038093

val2

0.087909

0.051981

1.691 0.092922 .

sat1

0.167089

0.070963

2.355 0.019866 *

sat2

-0.010561

0.047871

sat3

0.129468

0.057663

comp

0.078032

0.035151

loy1

0.011654

0.026656

loy2

-0.014807

0.020774

loy3

0.006408

0.042559

-0.296 0.767586

-0.221 0.825695 2.245 0.026244 * 2.220 0.027954 * 0.437 0.662602 -0.713 0.477100 0.151 0.880524

--Signif. codes:

0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 8.283 on 147 degrees of freedom Multiple R-squared:

0.6737,

Adjusted R-squared:

F-statistic: 15.97 on 19 and 147 DF,

0.6315

p-value: < 2.2e-16

#Now let’s compute the predictions and mean square prediction error for the linear regression. > predlm<-predict(modelm,testset1) > sumlm=0

Theophano Mitsa > tt<-length(predlm) > for(i in 1:tt) { + sumlm<-sumlm+(predlm[i]-testimean[i])^2 +} > sumlm 72 10123.05 > sumglm<-sumlm/tt # This is the mean square prediction error for the linear regression. > sumglm 72 121.9644

> library(pls) #Let’s create the model based on Principal Components Regression. > modelpcr<-pcr(trainimean~.,data=trainset1,validation="CV") #Let’s create the model based on Partial Least Squares Regression. > modelplsr<-plsr(trainimean~.,data=trainset1,validation="CV") #Let’s compute the predictions for the principal component and partial least squares models. > predpcr<-predict(modelpcr,testset1) > predpls<-predict(modelplsr,testset1) #Now, let’s compute the mean square errors for the above predictions. > sumpcr=0 > for(i in 1:tt) { + sumpcr<-sumpcr+(predpcr[i]-testimean[i])^2 +} > sumpcr [1] 6942.203 > sumg2<-sumpcr/tt

Theophano Mitsa #This is the mean square error for the principal components regression. > sumg2 [1] 83.641 > sumpls=0 > for(i in 1:tt) { + sumpls<-sumpls+(predpls[i]-testimean[i])^2 +} > sumpls [1] 7090.831 > sumg3<-sumpls/tt #This is the mean square error for the partial least squares error. > sumg3 [1] 85.4317 #Finally, let’s compute a model and predictions based on ridge regression. > library(ridge) >

ridge1_reg<-linearRidge(formula=trainimean~., data=trainset1,lambda="automatic")

> nn<-predict(ridge1_reg,testset1) > sumri=0 > for(i in 1:tt) { + sumri<-sumri+(nn[i]-testimean[i])^2 +} > sumri 72 8944.07 > sumg4<-sumri/tt #This is the mean square error for the ridge regression. > sumg4 72 107.7599

Theophano Mitsa # For a final benchmark, let us now compute the base error, which is computed by subtracting the mean of the mean image rating vector from the actual testset values. In other words, if we had no other knowledge we would use this mean value as our prediction. > mean(testimean) [1] 71.24627 > sumb=0 > for(i in 1:tt) { + sumb<-sumb+(testimean[i]-mean(testimean))^2 } > sumb [1] 15056.23 > sumgb<-sumb/tt #As we see, the base error is much larger than all previous errors. > sumgb [1] 181.4004

#Overall, we see that principal components regression and partial least squares regression have the smallest mean prediction errors.

princ comp reg.pdf

Now we will create the response variable for the training set, as the average of the 5 image. variables. > h1<-nrow(trainset). > trainimean<-numeric(h1). > for(i in ...

250KB Sizes 5 Downloads 184 Views

Recommend Documents

COLL/COMP COMP - ACS COMP Division
electrochemically active galena mineral .... Energy. Sponsored by MPPG, Cosponsored by ANYL, BIOL, COMP and ...... solar energy conversion devices: New.

COLL/COMP COMP - ACS COMP Division
Using the open source project, DataWarrior, for ... Relevance in Renewable Energy. & Environmental ... 2-dimensional organic frameworks for. CO2 capture.

Comp Catalog 2011 UPDATE NEW.indd - COMP Cams
First requirement when installing a steel roller cam. • Stock cast iron gears are not compatible with steel camshafts. • AMPCO-45 extruded aluminum bronze with ...

tmninata-kojato-predhozhda-tom-1-princ-na-nishhoto.pdf ...
Page 2 of 8. , - 1 ( , #1) by R. Scott Bakker. ››› Get audio book for free. ‹‹‹ Original Title: , - 1 ( , #1). ISBN: ISBN13: Autor: R. Scott Bakker/. / (Translator). Rating: 3.1 ...

Comp Know.pdf
Sign in. Page. 1. /. 13. Loading… Page 1 of 13. Page 1 of 13. Page 2 of 13. Page 2 of 13. Page 3 of 13. Page 3 of 13. Comp Know.pdf. Comp Know.pdf. Open.

NSE/COMP/34840 Date
May 10, 2017 - aforementioned notice of BSE, Exchange is in process of declaring this trading member as defaulter. Pending this ... [email protected].

NSE/COMP/34264 Date
Feb 24, 2017 - This is in continuation to Exchange circular download ref. no. NSE/COMP/34162 dated February. 10, 2017. The member Prrsaar has been granted stay by Hon'ble Securities Appellate Tribunal. (SAT) till March 7, 2017 and hence will not be s

SE(Comp) -
Explanation:In this program, We are using class to pass the value and then we are ..... a)101 b)102. C)103 d) none ans.d. Q62) what is the o/p of this program.

NSE/COMP/36213 Date
Nov 1, 2017 - This has reference to our Circular Ref. Nos. NSE/COMP/35648 dated August 23, 2017 and ... in order to avoid any late / non-submission charges as mentioned in our circular dated August 23, 2017. For and on behalf of. National Stock Excha

NSE/COMP/33988 Date
Jan 10, 2017 - SEBI confirmation regarding cancellation of registration is received. Such refund shall be ... Compliance department at toll free no. 1800 22 00 51 or at ... Telephone No. Fax No. Email id. 1800 22 00 51. +91-22- 26598428.

NSE/COMP/32412 Date
May 19, 2016 - ... of every year on or before May 31st of every year through ENIT and ... Telephone No. Fax No. Email id. 1800 22 00 51. +91-22-26598428.

NSE/COMP/34264 Date
Feb 24, 2017 - For and on behalf of. National Stock Exchange of India Ltd. Nipa Simaria. Chief Manager. Telephone No. Fax No. Email id. 1800 22 00 51.

SE(Comp) -
Explanation:In this program, We are using class to pass the value and then we .... #include using namespace std; template class Test.

NSE/COMP/34564 Date
Apr 5, 2017 - advised to take note of the above and ensure compliance. For and ... Fax No. Email id. 1800 22 00 51. +91-22-26598428 [email protected].

(CoMP) Transmission
proposed under the system model, where each iteration consists of an assignment step and a positioning step. ... and bm,j , are located at positions li and mj , for i = 1, ··· , L and j = 1, ··· , M. The energy-normalized ... Let Il,i and Im,j

SE(Comp) -
Consider the following program fragment that calls the method count_if in the C++ Standard. Template Library. .... Merge(x,x+5,y,y+4,z);. For(i=0;i

NSE/COMP/35972 Date
Sep 29, 2017 - For and on behalf of. National Stock Exchange of India Limited. Nipa Simaria. Chief Manager. Telephone No. Fax No. Email id. 1800 22 00 51.

NSE/COMP/37001 Date
Feb 20, 2018 - BSE vide Notice No. 20180219-30 dated February 19, 2018 expelled the trading member– Wealth. Mantra Limited. Pursuant to aforementioned notice of BSE, Exchange is in process of expelling this trading member in terms of Bye law 1A of

NSE/COMP/36334 Date
4 days ago - number. Last Trade Date. 1. IL & FS Broking Services Private. Limited. INZ230005738. 23-Nov- ... Email id. 1800 22 00 51. +91-22-26598428.

NSE/COMP/34920 Date
May 22, 2017 - ... year on or before May 31st of every year through ENIT and also be ... Telephone No. Fax No. Email id. 1800 22 00 51. +91-22-26598428.

Comp Networks NPTEL.pdf
There was a problem loading more pages. Retrying... Comp Networks NPTEL.pdf. Comp Networks NPTEL.pdf. Open. Extract. Open with. Sign In. Main menu.

technical program - ACS COMP Division
data. T.R. Clark, C. Kramer. 2:30 CINF 19. Reproducibility and the quality of chemical ... sharing of 3D molecular data. D. Koes, ... Increasing open communica-.

Comp Plan Changes.pdf
Proposed Plan Amendments. City Council Hearing June 21, 2016 ... Dresden Dr. and. Clairmont Rd. Ashford ... Displaying Comp Plan Changes.pdf. Page 1 of 57.

workers comp PDF.pdf
Page 1 of 27. Page 1 of 27. Page 2 of 27. Page 2 of 27. Page 3 of 27. Page 3 of 27. workers comp PDF.pdf. workers comp PDF.pdf. Open. Extract. Open with.