我的问题很简单:如果我有一个LM模型,其中预测变量通过sqrt()
进行转换,我该如何将其转换回来绘制它?
Time=seq.POSIXt(as.POSIXct("2016-10-01 00:00:00",format="%Y-%m-%d %H:%M:%S"),
as.POSIXct("2016-12-01 23:50:00",format="%Y-%m-%d %H:%M:%S"),
by="10 min")
MyData=data.frame(Timestamp=Time,x1=rnorm(length(Time),mean=20,sd=10),x2=rnorm(length(Time),mean=25,sd=10),x3=rnorm(length(Time),mean=30,sd=10),
Sum_Column=rep(0,length(Time)))
MyData$Sum_Column=(rowSums(MyData[,c("x1","x2","x3")]))/3
LM_Sum_Column=lm(sqrt(Sum_Column) ~ x1 + x2 + x3, data=MyData, na.action = na.exclude)
plot(MyData$Sum_Colum~MyData$Timestamp,type="h")
lines(predict.lm(LM_Sum_Column, data=MyData)~MyData$Timestamp,type="l", col="red")
如果同时绘制原始值和LM,则会看到由于平方值导致的较大差异。如何将它们带回"正常"?