Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201943

linear regression model using R

$
0
0

I am a novice in R but am trying to learn. I have a dataset in excel and i import it in R using:

stockPrice<-read.csv("C:/Users/Desktop/prova.csv", sep=";", header=T, check.names = FALSE, stringsAsFactors=FALSE)

and the result of the import is this. there are 100 rows and columns.

        1       2       3      4       5       6       7      8       9     10      11      12
1  -1,8669 -1,2096  1,0358 0,0239 -1,0284 -0,0259  0,8801 0,4778  1,1449 0,4397 -0,1530 -0,3123
2  -2,1469 -0,4331 -0,0891 1,3842 -1,4148  0,1138 -0,8275 0,5115 -1,2898 1,8105  0,8521 -1,4327
3  -1,8919 -0,6469 -0,4098 2,8243 -1,3704 -1,6783 -0,6159 1,2910 -1,4260 2,4720  0,5230 -1,6965
4  -0,7912  0,4075  0,1092 3,8167 -0,9085 -1,0804  0,4104 0,9577 -0,2531 1,1191  1,5688 -0,8727
5  -0,2726  0,1827  0,7973 3,3848  1,0666  1,1254 -1,4111 1,2030 -0,9559 1,7813  1,8331 -1,0933
6   0,0539 -0,8640  2,0607 3,4989  2,1625  0,5226 -1,3890 2,6475 -0,6684 0,4587  0,7694  0,3462
7   0,6813 -1,9639  0,1362 1,9797  2,8645 -0,1524 -1,2367 4,6739 -1,7459 2,2648  1,8341 -0,4107
8  -0,4228 -0,3357  0,1201 2,1603  4,2053 -0,3679 -0,5577 3,7251 -1,6288 2,0168  1,1571 -0,8601
9   0,3020 -0,0523  1,4912 2,6993  5,2069 -0,0497 -0,3139 3,2010 -1,1773 1,8993  0,3357 -3,4239
10 -0,0832  0,2051  2,2387 2,9303  6,1984  1,9706 -0,3759 2,7283 -2,1752 2,0772  0,3298 -4,3092

I just copy part of the dataset. each column is referred to an asset. Now, what am trying to do is to calculate a linear regression, for example, the first asset y will be column 1 row from 1 to 9 and x will be column 1 row from 2 to 10.And I have to do this for each asset.i just need the value of the coefficient.


Viewing all articles
Browse latest Browse all 201943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>