[R-sig-Geo] Interpolating
Tom Gottfried
tom.gottfried at o2mail.de
Mon Aug 20 10:16:23 CEST 2012
Am 20.08.2012 05:08, schrieb K Jjw:
> Hi
> I tried predict but I get an error. Warning message: 'newdata' had 4 rows but variable(s) found have 3 rows
> it only works if the number of rows that i am trying to predict are the same as the original number of rows (3). It does however work when I try to do the same thing for example in ?predict (tried with 17 rows to predict when the original function is 15 rows) . Not sure what is going on. Has anyone run into the same problem before?
Not sure what is going on neither. But a reproducible example would
surely help you and others on the list to get to know what is going on.
Regards,
Tom
> Thanks
> KJ
>
>
>
> ?predict
> ?predict.lm
>
> HTH,
> Tom
>
> Am 15.08.2012 04:05, schrieb K Jjw:
>> Hi
>>
>>
>> I have data that are from 1990, 2040, and 2090. I
> need to loop through each location (defined in a grid of 240x260) and find a
> linear regression for each place across the 3 years. I then need to interpolate
> the data to get the missing years for the given location ie I need all the data
> for 1991, 1992, 1993 etc. I have a loop and I have figured out how to make the
> model ie lm(). What I am having difficulty with is interpolating the data
> without hardcoding in the formula of the linear regression.
>>
>> so basically the bit of code that is causing me
> problems is
>>
>> linr<-lm(jan_ppt~date)
>> linr
>>
>> Call:
>> lm(formula = jan_ppt ~ date)
>>
>> Coefficients:
>> (Intercept) date
>> 1.482e+02 1.728e-03
>>
>> x<- 1990:2090
>> y<-1.482e2 + 1.728e-3*x #this is what I have now
>> y<- intercept+ grad*x #this is what I want where
> 'intercept' and 'grad' are defined from the model 'linr'
>>
>> how do I
> define y without hardcoding the coefficients as they will change for every
> location. I basically need to do linear regressions for each location then
> interpolate the data to get yearly data in order to put this data in another
> model that requires yearly data.
>>
>> Thanks
>>
>> KJ
>> [[alternative
> HTML version deleted]]
>>
>>
>>
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> [[alternative HTML version deleted]]
>
>
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list