0

I have a dataset of type:

num     col1    col2  col3  col4  col5  col6 
row1      8.186 8.176 8.171 8.159 8.152 8.141     
row2      7.644 7.649 7.656 7.664 7.668 7.665      
row3      7.130 7.152 7.168 7.207 7.229 7.251      
row4      8.711 8.720 8.723 8.728 8.734 8.729      
row5      6.771 6.795 6.827 6.828 6.848 6.852 

I basically need to do quadratic fits of each row as a function of (0.1,20,40,80,120,160).

For example I need to do

y = c(8.186, 8.176, 8.171, 8.159, 8.152, 8.141)
x = c(0.1,20,40,80,120,160)

and do the quadratic fit of y vs x.

I have ~300 ROWS of data to be fit as a function of x. I appreciate any help!

  • I might have explained my problem poorly. As suggested by Zheyuan's link, I have a similar problem. But I don't see how the problem of doing many fits at once was achieved in that post. If I were to follow the solution of that problem, I need to transpose my dataset (df) and type all ~300 independent responses manually. So could anyone please help me to automate this process? – Zhalgas May 04 '17 at 10:12
  • How's the following? #create the data data<-data.frame(num=1:5,v1=c(8.1,7.6,7.1,8.7,6.7),v2=c(8.1,7.6,7.1,8.7,6.8),v3=c(8.1,7.6,7.2,8.7,6.8)) p=data.frame(variable=c("v1","v2","v3"),p=c(1,2,4)) #Transform and merge data to get as two separate columns library(reshape2) data2<-melt(data,id.var="num") data3<-merge(data2,p) #Run a mixed effects model with p as an independent, varying by num library(lme4) mod<-lmer(value~0+(0+p|num),data=data3) ranef(mod) #get the coefficients of each – Jason Dealey May 05 '17 at 16:02

0 Answers0