Define your measurement error design

medesign(model_syntax, .data, me_data, drop_sscore_vars = TRUE, ...)

Arguments

model_syntax

A description of the user-specified model as a character string. The model is described using the me model syntax. See the details and example section for on how to write this syntax.

.data

a data frame containing all variables defined in model_syntax

me_data

A data frame of class me. Can be created manually with me_construct. It is expected that this measurement error data is not square rooted (reliability, validity and quality) as it will be done with me_sscore.

drop_sscore_vars

Whether to remove variables that compose a sum score from the final correlation. More specifically, if you define the sum score s1 = v1 + v2, then v1 and v2 are excluded from the final correlation. The default is to exclude these columns since you can get correlation coefficients over one for these variables. Default set to TRUE.

...

arguments passed to me_sscore.

Value

an me design object which can be passed to other functions of cosme such as me_cmv_cor and me_cmv_cov.

Details

The model syntax allows to define the relationship between variables in terms of how to correct for their measurement error and whether they share a common method in the question that was asked. To correct for the measurement error of a set of variables you can write the model like this:

~~ stflife + stfwork

For most purposes, a user would just want to correct for measurement error on all variables which have measurement error statistics in me_data and is present on .data. For that, ~~ is interpreted as a normal R formula so you can automatically apply the correction to all variables like this:

~~ .

Correcting for measurement error (that is, using `~~`) is a necessary step for `medesign`. That is, it always needs to be specified as it is the first step on which other corrections are built. medesign will raise an error if no `~~` is specified.

For correcting for common method variance, the syntax is virtually the same but exchanging `~~` for `~`. For example, if the questions called stflife and stfwork were both measured with a 1-10 likert scale related to satisfaction, these two questions were measured with the same method. The model syntax would specify them like:

~ stflife + stfwork

These two questions should also be in .data and in me_data, otherwise no calculation can be performed. .data should be a data frame with all variables specified in the model_syntax while me_data should be a data frame with 4 columns: question, reliability, validity an quality. The first column should contain the names of the variables as character vector, while the other three should be numeric vectors with their corresponding reliability, validity and quality values.

The model syntax also allows you to create 'new variables' and also specify whether these new variables share a common method. For example, we can add the variables /codetrstplt, trstprl, trstprt together and then specify that the new 'sum score' variable shares a common method with the variables stflife and stfwork. We would write it like this:

# Correct for measurement error of all variables
~~ .

# Creation of new variables
std(new_variable) = trstplt + trstprl + trstprt

# Correct for common method variance
~ new_variable + stflife + stfwork

You can also combine these building blocks to specify a shared common method between two new variables. For example:

# Quality correction
~~ .

# Creation of new variables
std(new_variable1) = trstplt + trstprl + trstprt
std(new_variable2) = stflife + stfwork

# Correction for common method
~ new_variable1 + new_variable2

Note that the operator std() just works to specify the we want this new variable to be standardized.

Currently, medesign replaces the non-NA quality of all variables found in me_data and .data in the correlation/covariance diagonal by default. This is then used by me_cmv_cor and me_cmv_cov to correct for the quality in the diagonal.

Author

Jorge Cimentada and Wiebke Weber

Examples


data(ess7es)
# Correct for measurement error for all variables
# and correct for the fact that these three variables
# share a common method
me_syntax <- "~~ .; ~ trstplt + trstprl + trstprt"

# Data from sqp
me_data <-
  data.frame(
    question = c("trstprl", "trstplt", "trstprt"),
    reliability = c(0.812, 0.852, 0.858),
    validity = c(0.959, 0.965, 0.956),
    quality = c(0.779, 0.822, 0.821)
  )

medesign(me_syntax, ess7es, me_data)
#> Correcting for measurement error in trstprl, trstplt, trstprt. If you want to correct other variables, make sure they are both in `me_data` and `.data` and you specify their names in the model syntax (`~~`).
#> <Measurement error design>
#> Parsed model:
#>    ~~ trstprl + trstplt + trstprt
#>    ~ trstplt + trstprl + trstprt

# Each pair of variables share a common method.
me_syntax <-
 "~~ .;
  ~ trstplt + trstprl + trstprt
  ~ stfedu + stfhlth"

me_data2 <-
  data.frame(
    question = c("stfedu", "stfhlth"),
    reliability = c(0.757, 0.760),
    validity = c(0.838, 0.798),
    quality = c(0.635, 0.607)
  )

me_data <- rbind(me_data, me_data2)

medesign(me_syntax, ess7es, me_data)
#> Correcting for measurement error in trstprl, trstplt, trstprt, stfedu, stfhlth. If you want to correct other variables, make sure they are both in `me_data` and `.data` and you specify their names in the model syntax (`~~`).
#> <Measurement error design>
#> Parsed model:
#>    ~~ trstprl + trstplt + trstprt + stfedu + stfhlth
#>    ~ trstplt + trstprl + trstprt
#>    ~ stfedu + stfhlth

# We can also create new variables and use them
# as variables sharing a common method

me_syntax <-
 "~~ .;
  std(new_sscore1) = trstplt + trstprl + trstprt;
  ~ new_sscore1 + stfedu + stfhlth"

medesign(me_syntax, ess7es, me_data)
#> Correcting for measurement error in stfedu, stfhlth, new_sscore1. If you want to correct other variables, make sure they are both in `me_data` and `.data` and you specify their names in the model syntax (`~~`).
#> <Measurement error design>
#> Parsed model:
#>    new_sscore1 = trstplt+trstprl+trstprt
#>    ~~ stfedu + stfhlth + new_sscore1
#>    ~ new_sscore1 + stfedu + stfhlth

# Alternatively, we can also combine two newly created variables
# as sharing a common method
me_syntax <-
 "std(new_sscore1) = trstplt + trstprl + trstprt;
  std(new_sscore2) = stfedu + stfhlth;
  ~~ .;
  ~ new_sscore1 + new_sscore2"

medesign(me_syntax, ess7es, me_data)
#> Correcting for measurement error in new_sscore1, new_sscore2. If you want to correct other variables, make sure they are both in `me_data` and `.data` and you specify their names in the model syntax (`~~`).
#> <Measurement error design>
#> Parsed model:
#>    new_sscore1 = trstplt+trstprl+trstprt
#>    new_sscore2 = stfedu+stfhlth
#>    ~~ new_sscore1 + new_sscore2
#>    ~ new_sscore1 + new_sscore2