[R-meta] standard error in predictive nonlinear meta-regression

Viechtbauer Wolfgang (SP) wolfgang.viechtbauer at maastrichtuniversity.nl
Mon Jan 22 13:11:45 CET 2018


Hi Cesar,

Please keep the mailing list cc-ed.

predict() does not have a 'na.rm' argument. You can however set the method for handling missings via options(). See:

http://www.metafor-project.org/doku.php/tips:handling_missing_data

Best,
Wolfgang

>-----Original Message-----
>From: Cesar Terrer Moreno [mailto:cesar.terrer at me.com]
>Sent: Monday, 22 January, 2018 12:29
>To: Viechtbauer Wolfgang (SP)
>Subject: Re: [R-meta] standard error in predictive nonlinear meta-
>regression
>
>Hi Wolfgang, thanks for your suggestion. This is giving me an error
>though:
>
>> ECMrelSE <- predict(ECMmeta,
>+                     newmods = cbind(s[["precipitation"]],
>s[["temperature"]], 300, s[["temperature"]]*300))
>Error in Xi.new %*% x$beta :
>  requires numeric/complex matrix/vector arguments
>
>Alternatively, I have transformed the dataset from a raster stack to a
>dataset with coordinates x,y:
>
>s.df = as.data.frame(s,xy=TRUE)
>ECMrelSE <- predict(ECMmeta, addx=T, na.rm=FALSE,
>                    newmods = cbind(s.df2$precipitation,
>s.df2$temperature, 300, s.df2$temperature*300))
>
>This produces what I needed. The problem is that I need the x and y
>coordinates from s.df to bee included in ECMrelSE in order to transform
>the dataset back to a grid and map SE values. Therefore:
>
>> ECMrelSE2 <- cbind(s.df[,c("x", "y")], ECMrelSE$se)
>Error in data.frame(..., check.names = FALSE) :
>  arguments imply differing number of rows: 1036800, 281612
>
>I think this is because the predict function removes all rows with NAs,
>so the resulting ECMrelSE has less rows than s.df and the x and y columns
>cannot be bound with the SE predictions.
>
>Any idea how I can fix this? Thanks
>César
>
>> On 20 Jan 2018, at 20:27, Viechtbauer Wolfgang (SP)
><wolfgang.viechtbauer at maastrichtuniversity.nl> wrote:
>>
>> I do not know the overlay() function, but the 'newmods' argument of
>predict() can also take multiple rows, so something like this:
>>
>> MAPvals <- seq(0, 2, by=0.1)
>> MATvals <- seq(1, 10, by=1)
>> X <- expand.grid(MAP=MAPvals, MAT=MATvals)
>> X <- cbind(X, 300, X$MAT*300)
>> predict(ECMmeta, newmods = X)
>>
>> You still might need to do some further restructuring.
>>
>> Best,
>> Wolfgang
>>
>>> -----Original Message-----
>>> From: Cesar Terrer Moreno [mailto:cesar.terrer at me.com]
>>> Sent: Saturday, 20 January, 2018 19:08
>>> To: Viechtbauer Wolfgang (SP)
>>> Cc: r-sig-meta-analysis at r-project.org
>>> Subject: Re: [R-meta] standard error in predictive nonlinear meta-
>>> regression
>>>
>>> Hi Wolfgang,
>>>
>>> Thanks for your response.
>>>
>>> Do you know how I could apply this model to predict effect size on a
>grid
>>> (i.e. on a per pixel basis) for the entire world, with known MAP
>>> (precipitation) and MAT (temperature) per pixel coming from maps, and
>a
>>> fix COdif=300?
>>>
>>> Something like:
>>>
>>> ECMrelSE <- overlay(s[["temperature"]], s[["precipitation"]],  #
>raster
>>> maps for MAT and MAP, respectively
>>>                   fun=predict(ECMmeta, newmods = c(MAP, MAT, 300,
>>> MAT*300)))
>>>
>>> The above doesn’t work.
>>>
>>> Thanks
>>> César
>>>
>>>> On 20 Jan 2018, at 10:33, Viechtbauer Wolfgang (SP)
>>> <wolfgang.viechtbauer at maastrichtuniversity.nl> wrote:
>>>>
>>>> Use predict(). In this case:
>>>>
>>>> predict(ECMmeta, newmods = c(2, 3, 4, 3*4))
>>>>
>>>> where MAP=2, MAT=3, CO2dif=4, and hence MAT*CO2dif=3*4.
>>>>
>>>> Best,
>>>> Wolfgang
>>>>
>>>>> -----Original Message-----
>>>>> From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces at r-
>>>>> project.org] On Behalf Of Cesar Terrer Moreno
>>>>> Sent: Friday, 19 January, 2018 13:45
>>>>> To: r-sig-meta-analysis at r-project.org
>>>>> Subject: [R-meta] standard error in predictive nonlinear meta-
>>> regression
>>>>>
>>>>> Dear all,
>>>>>
>>>>> Yesterday I could solve my question re SE in a nonlinear model
>>> following
>>>>> Phillip and Wolfgang’s great suggestions using the delta method.
>>>>>
>>>>> Now I need to compute SE for a linear meta-regression:
>>>>>
>>>>>> summary(ECMmeta <- rma(es, var, data=ecm ,control=list(stepadj=.5),
>>>>> mods= ~ 1 + MAP + MAT*CO2dif, knha=TRUE))
>>>>>
>>>>> Model Results:
>>>>>
>>>>>          estimate      se     tval    pval    ci.lb    ci.ub
>>>>> intrcpt       0.5754  0.1828   3.1481  0.0031   0.2057   0.9451   **
>>>>> MAP           0.0002  0.0001   2.6648  0.0111   0.0000   0.0003    *
>>>>> MAT          -0.0589  0.0179  -3.2842  0.0022  -0.0952  -0.0226   **
>>>>> CO2dif       -0.0019  0.0007  -2.7384  0.0093  -0.0032  -0.0005   **
>>>>> MAT:CO2dif    0.0002  0.0001   3.6366  0.0008   0.0001   0.0003  ***
>>>>>
>>>>> How can I compute SE for a particular pixel with known MAP, MAT and
>>>>> CO2dif?
>>>>> Thanks


More information about the R-sig-meta-analysis mailing list