# Why standard deviation is needed when doing meta analysis?

I want to build a model, and use the predict.

``````library(dplyr)
model <-  brm(data = datain, d | se(se , sigma=TRUE) ~ 1 + (1 | study) + (1 | outcome))
newdata = datain %>% select('outcome','study')
predict(b14.6, newdata)
``````

However, there is an error:

``````Error: The following variables can neither be found in 'data' nor in 'data2':
'se'
``````

How could I fix the error? I think the sd should be a dependent variable instead of an independent variable in the model…

When you call`se(var)` in `brms` you’re specifying that your dataset contains a variable called `var` which contains the standard error for each observation. If you don’t want to include the standard errors, then you can simply omit the `se()` call.

When performing a meta-analysis you generally need to have both the estimate of the effect (Cohen’s d, etc.), as well as the standard error (SE) of that estimate. The SE is used as a means of summarising the level of uncertainty that we have in a given effect estimate. For example, if two studies reported a Cohen’s d of 2 but one of them used a sample size of 10 and the other a sample size of 100, we would have much less confidence in the accuracy of the smaller study’s effect estimate.

Hi Andrjohns,

But I still need your help.

Our data indeed have both estimation as well as the standard error for each country. But for one country, there are multiply rows (data records), so I want to get a summarized estimate together with standard error for each country.

So if this model with prediction function does not work, which model or functions should I use for prediction?

Best,
Dingyao

In your above code, which line causes the error? Is it this one:

``````model <-  brm(data = datain, d | se(se , sigma=TRUE) ~ 1 + (1 | study) + (1 | outcome))
``````

No, the error happens in the prediction process.

Oh I see what you mean, apologies for the initial mix-up! Yes, you will always need the `se` input when making predictions for new data, as the model still needs to know the level of uncertainty when making predictions.

If you have data with multiple records per country, you can also include a random intercept for country in the model. This would then allow you to estimate the ‘overall’ effect size for each country when post-processing the model (using the `coef` function).

So what I want to do is that firstly, I want to use independent variables to model standard errors. Secondly, I want to use the standard errors which are gotten from the first step and other independent variables to predict the responsive variable and then get the estimation as well as the standard error for it. Is it possible?

Yes, you would just need to have two models. In the first model you have standard errors as your outcome, with whichever predictors. Then you can use that model to predict new standard errors to be passed to the meta-analysis model

Thank you very much!!!

So how should I write the model?

``````model <-  brm(data = datain, d | se(se , sigma=TRUE) ~ 1 + (1 | study) + (1 | outcome))
``````

Use two formulas to replace the only formula in this commands？

To be exact, I have modeled se as a responsive variable. However, I still had the same error…

``````model <-  brm(data = spank, formula = bf(d | se(se,sigma = TRUE)  ~ 1 + (1 | study), sigma ~ study ))

> datain[1,]
# A tibble: 1 x 9
study                    year outcome            between within     d    ll    ul    se
<chr>                   <dbl> <chr>                <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>
1 Bean and Roberts (1981)  1981 Immediate defiance       1      0 -0.74 -1.76  0.28 0.520

> predict(object=model, newdata=datain[1,])
Estimate Est.Error       Q2.5    Q97.5
[1,] 0.1318883 0.5347633 -0.8580596 1.136997
> predict(object=model, newdata=datain[1,-9])
Error: The following variables can neither be found in 'data' nor in 'data2':
'se'
> predict(object=model, newdata=datain[1,-6])
Estimate Est.Error       Q2.5    Q97.5
[1,] 0.1976987 0.5636397 -0.8397344 1.262325

>
``````

How should I adjust the model ← brm(…) command to make the prediction without standard error possible?