Title: | Social Relations Analyses with Roles ("Family SRM") |
---|---|
Description: | Social Relations Analysis with roles ("Family SRM") are computed, using a structural equation modeling approach. Groups ranging from three members up to an unlimited number of members are supported and the mean structure can be computed. Means and variances can be compared between different groups of families and between roles. |
Authors: | Felix Schönbrodt, Lara Stas, Tom Loeys |
Maintainer: | Felix Schönbrodt <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.6.5 |
Built: | 2024-11-21 04:20:13 UTC |
Source: | https://github.com/cran/fSRM |
Build lavaan syntax for a Social Relations Model with roles ("Family SRM"). This function is called by the fSRM function, but can be also called directly to build an appropriate lavaan syntax.
buildSRMSyntax( roles, var.id, self = FALSE, IGSIM = list(), drop = "default", err = "default", means = FALSE, diff = FALSE, pairwise = FALSE, groupnames = NULL, add.variable = c(), selfmode = "cor", noNegVar = FALSE, rolesEqual = FALSE, ... )
buildSRMSyntax( roles, var.id, self = FALSE, IGSIM = list(), drop = "default", err = "default", means = FALSE, diff = FALSE, pairwise = FALSE, groupnames = NULL, add.variable = c(), selfmode = "cor", noNegVar = FALSE, rolesEqual = FALSE, ... )
roles |
A vector with all role labels. |
var.id |
A vector with the variable names of the DV indicators |
self |
Should self-ratings be included in the analysis (if present in the data set)? |
IGSIM |
Define intragenerational similarity correlations. Must be a list where the levels of actor.id and partner.id are combined, e.g.: |
drop |
In three-member families at least one component has to be dropped. |
err |
Defines the type of correlations between error terms. err = "no": no error term correlations - this is the required mode for single indicators. err = "all": If multiple indicators are present, correlate same items BETWEEN raters (e.g., Dyadic Data Analysis, Kenny, Kashy, & Cook, 2000). err = "default": Set err to "no" for single indicators and to "all" for multiple indicators. |
means |
Should the structured means of the SRM factors be calculated? |
diff |
Compare groups with the delta method? |
pairwise |
Compute pairwise comparison of actor and partner means between all roles? Only works when |
groupnames |
Vector with the names of the groups (i.e., the values of the group column in the data set) |
add.variable |
Not yet fully implemented: Add external variables to the model syntax. |
selfmode |
Defines the style how the selfratings are combined with the latent actor and partner effects. If |
noNegVar |
Should variance estimates be constrained to be positive? |
rolesEqual |
Maximal constraints: Do roles matter at all? If this parameter is set to TRUE, it is a model with no mean difference, the actor variances equal, partner variances equal, relationship variances equal, and the respective reciprocities equal (Thanks to a suggestion of David Kenny). Model comparisons via |
... |
Additional arguments (not documented yet) |
None.
Kenny, D. A., & West, T. V. (2010). Similarity and Agreement in Self-and Other Perception: A Meta-Analysis. Personality and Social Psychology Review, 14(2), 196-213. doi:10.1177/1088868309353414
In sum, this dataset contains a measures of negativity for each of the 12 relationships.
Four roles are present: Mothers "M", fathers "F", the asolescent with externalizing problem behavior "T", and the adolescent sibling without problem behavior "S".
A wide version of the same data set is in clinical.wide
.
data(clinical)
data(clinical)
The variables are as follows:
family.id An indicator for the family.
actor.id An indicator for the perceiver, either "M", "F", "T", or "S".
partner.id An indicator for the target, either "M", "F", "T", or "S".
neg Negativity measure.
Test actor and partner means for equality, using a Wald test.
equalMeans(x, digits = 3)
equalMeans(x, digits = 3)
x |
A fSRM object- |
digits |
Digits to which the printed results are rounded |
The classic Cook (2000) dataset consists of measurements on security of attachment within families. Only the variable measuring fear of rejection in family relationships is included in this dataset. Cook (2000) deduced this variable from the anxiety dimension of the adult attachment scale (Collins & Read, 1990). The original data consisted of four person families (i.e. two parents and two children): the mother is labeled as "m", the father as "f", the oldest child as "c" and the youngest child as "y".
A data frame with 2497 rows and 4 variables (208 families with 4 members each, round-robin design)
The variables are as follows:
family.id An indicator for the family.
actor.id An indicator for the rater in the dyad, either "m", "f", "c", or "y"
partner.id An indicator for the person being rated in the dyad, either "m", "f", "c", or "y"
anx: The obtained score on the attachment anxiety scale.
This dataset was retrieved from http://davidakenny.net/kkc/c9/c9.htm in wide format and converted to an R dataset in long format.
Cook, W. L. (2000). Understanding attachment security in family context. Journal of Personality and Social Psychology, 78, 285-294. doi:10.1037/0022-3514.78.2.285
Collins, N. L., & Read, S. J. (1990, April). Adult attachment, working models, and relationship quality in dating couples. Journal of Personality and Social Psychology, 58, 644-663.
data(four.person) head(four.person)
data(four.person) head(four.person)
Run a Social Relations Model with roles ("Family SRM")
fSRM( formula = NULL, data, drop = "default", add = "", means = FALSE, pairwise = FALSE, diff = FALSE, IGSIM = list(), add.variable = c(), syntax = "", group = NULL, noNegVar = FALSE, rolesEqual = FALSE, missing = NA, ... )
fSRM( formula = NULL, data, drop = "default", add = "", means = FALSE, pairwise = FALSE, diff = FALSE, IGSIM = list(), add.variable = c(), syntax = "", group = NULL, noNegVar = FALSE, rolesEqual = FALSE, missing = NA, ... )
formula |
A formula that defines the variable names. Should be in one of following formats: (1) Single manifest dependent variable: DV ~ actor.id * partner.id | group.id, (2) Multiple indicators for dependent variable: DV1/DV2/DV3 ~ actor.id * parter.id | group.id. |
data |
A data frame with all variables defined by |
drop |
In three-member families at least one component has to be dropped. |
add |
Additional lavaan syntax pasted at the end of the generated model. Can contain, for example, user specified error correlations. |
means |
Should the structured means of the SRM factors be calculated? |
pairwise |
Compute pairwise comparison of actor and partner means between all roles? Only works when |
diff |
Compare groups with the delta method? You need to specify a group identifier in parameter |
IGSIM |
Define intragenerational similarity correlations. Must be a list where the levels of actor.id and partner.id are combined, e.g.: |
add.variable |
Not yet fully implemented: Add external variables to the model syntax. |
syntax |
In that variable the user can directly provide a lavaan model syntax. Then no automatical model syntax is generated. |
group |
Variable name indicating group membership. This can be used two compare two classes of families (e.g., clinical families vs. control families). If this variable is provided, it must contain exactly two levels. |
noNegVar |
Should variance estimates be constrained to be positive? |
rolesEqual |
Maximal constraints: Do roles matter at all? If this parameter is set to TRUE, it is a model with no mean difference, the actor variances equal, partner variances equal, relationship variances equal, and the respective reciprocities equal (Thanks to a suggestion of David Kenny). Model comparisons via |
missing |
Handling of missing values. By default ( |
... |
Additional arguments passed to the |
A model can be rerun with additional syntax using the add
function:
s1 <- fSRM(dep1/dep2 ~ actor*partner | fam, dat2)
s2 <- add(s1, "Ac ~~ Pm")
A model can be run with new parameters using the update function:
s1 <- fSRM(dep1/dep2 ~ actor*partner | fam, dat2)
s2 <- update(s1, diff=TRUE)
The fSRM
function relies on the lavaan
package for computation: A syntax for the SRM with roles is generated and then passed to the lavaan
function. Hence, many options of the lavaan
function can be used out-of-the-box (additional parameters are passed to the lavaan
function through the ...
operator). For example, one can deal with missing values. The default behavior is to exclude families with missing values (listwise deletion). Set fSRM(..., missing="fiml")
for ML / FIML estimation. Or, you can request bootstrapped standard errors with fSRM(..., se="boot")
.
You can test for a very restricted model by constraining the roles to be equal ("Do roles matter at all?"). Therefore, compare a model with free roles (m1 <- fSRM(..., means=TRUE, rolesEqual = FALSE)
) with a model with equal roles (m2 <- fSRM(..., means=TRUE, rolesEqual=TRUE)
) using anova(m1$fit, m2$fit)
(Thanks to David Kenny for the suggestion).
For plotting relative variances and mean structure, see plot.fSRM
.
Kenny, D. A., & West, T. V. (2010). Similarity and Agreement in Self-and Other Perception: A Meta-Analysis. Personality and Social Psychology Review, 14(2), 196-213. doi:10.1177/1088868309353414
# Example from Dyadic Data Analysis data(two.indicators) # 4 persons, 1 indicator f4.1 <- fSRM(dep1 ~ actor.id*partner.id | family.id, two.indicators) f4.1 # by default, one-sided p-values and CIs are printed for variances print(f4.1, var.onesided=FALSE) # Show two-sided p-values and CIs for variances plot(f4.1) # plot relative variances plot(f4.1, bw=TRUE) ## Not run: # 4 persons, 2 indicators f4.2 <- fSRM(dep1/dep2 ~ actor.id*partner.id | family.id, two.indicators) f4.2 plot(f4.2, bw=TRUE) plot(f4.2, bw=TRUE, onlyStable=TRUE) # 4 persons, 1 indicator, mean structure f4.1.m <- fSRM(dep1 ~ actor.id*partner.id | family.id, two.indicators, means=TRUE) f4.1.m plot(f4.1.m, means=TRUE) # plot mean structure # 4 persons, 2 indicators, mean structure f4.2.m <- fSRM(dep1/dep2 ~ actor.id*partner.id | family.id, two.indicators, means=TRUE) f4.2.m # ... add intragenerational similarity (now results are identical to Cook, 2000) f4.ig <- fSRM(dep1/dep2 ~ actor.id*partner.id | family.id, two.indicators, IGSIM=list(c("m", "f"), c("c", "y"))) f4.ig ## ====================================================================== ## Wald-test for equality of means ## ====================================================================== f4.1.m <- fSRM(dep1 ~ actor.id*partner.id | family.id, two.indicators, means=TRUE) f4.1.m equalMeans(f4.1.m) # construct a 3-person data set two.indicators3 <- two.indicators[two.indicators$actor.id != "y" & two.indicators$partner.id != "y", ] f3.2.m <- fSRM(dep1/dep2 ~ actor.id*partner.id | family.id, two.indicators3, means=TRUE) f3.2.m equalMeans(f3.2.m) # --------------------------------------------------------------------- # Run analyses based on Eichelsheim, V. I., Buist, K. L., Dekovic, M., Cook, W. L., Manders, W., Branje, S. J. T., Frijns, T., et al. (2011). Negativity in problematic and nonproblematic families: A multigroup social relations model analysis with structured means. Journal of Family Psychology, 25, 152-156. doi:10.1037/a0022450 # The data set is a simulated data set which has # comparable properties as the original data set data(two.groups) str(two.groups) E1 <- fSRM(neg ~ actor.id*partner.id | family.id, data=two.groups) E1 # make group comparison: # group = 1: non-problematic families, group = 2: problematic families # The data set must contain exactly two groups, otherwise an error is printed E2 <- fSRM(neg ~ actor.id*partner.id | family.id, data=two.groups, group="group") E2 # Compare means and differences between groups. Beware: This model takes *really* long ... E3 <- fSRM(neg ~ actor.id*partner.id | family.id, data=two.groups, group="group", means=TRUE, diff=TRUE) E3 ## End(Not run)
# Example from Dyadic Data Analysis data(two.indicators) # 4 persons, 1 indicator f4.1 <- fSRM(dep1 ~ actor.id*partner.id | family.id, two.indicators) f4.1 # by default, one-sided p-values and CIs are printed for variances print(f4.1, var.onesided=FALSE) # Show two-sided p-values and CIs for variances plot(f4.1) # plot relative variances plot(f4.1, bw=TRUE) ## Not run: # 4 persons, 2 indicators f4.2 <- fSRM(dep1/dep2 ~ actor.id*partner.id | family.id, two.indicators) f4.2 plot(f4.2, bw=TRUE) plot(f4.2, bw=TRUE, onlyStable=TRUE) # 4 persons, 1 indicator, mean structure f4.1.m <- fSRM(dep1 ~ actor.id*partner.id | family.id, two.indicators, means=TRUE) f4.1.m plot(f4.1.m, means=TRUE) # plot mean structure # 4 persons, 2 indicators, mean structure f4.2.m <- fSRM(dep1/dep2 ~ actor.id*partner.id | family.id, two.indicators, means=TRUE) f4.2.m # ... add intragenerational similarity (now results are identical to Cook, 2000) f4.ig <- fSRM(dep1/dep2 ~ actor.id*partner.id | family.id, two.indicators, IGSIM=list(c("m", "f"), c("c", "y"))) f4.ig ## ====================================================================== ## Wald-test for equality of means ## ====================================================================== f4.1.m <- fSRM(dep1 ~ actor.id*partner.id | family.id, two.indicators, means=TRUE) f4.1.m equalMeans(f4.1.m) # construct a 3-person data set two.indicators3 <- two.indicators[two.indicators$actor.id != "y" & two.indicators$partner.id != "y", ] f3.2.m <- fSRM(dep1/dep2 ~ actor.id*partner.id | family.id, two.indicators3, means=TRUE) f3.2.m equalMeans(f3.2.m) # --------------------------------------------------------------------- # Run analyses based on Eichelsheim, V. I., Buist, K. L., Dekovic, M., Cook, W. L., Manders, W., Branje, S. J. T., Frijns, T., et al. (2011). Negativity in problematic and nonproblematic families: A multigroup social relations model analysis with structured means. Journal of Family Psychology, 25, 152-156. doi:10.1037/a0022450 # The data set is a simulated data set which has # comparable properties as the original data set data(two.groups) str(two.groups) E1 <- fSRM(neg ~ actor.id*partner.id | family.id, data=two.groups) E1 # make group comparison: # group = 1: non-problematic families, group = 2: problematic families # The data set must contain exactly two groups, otherwise an error is printed E2 <- fSRM(neg ~ actor.id*partner.id | family.id, data=two.groups, group="group") E2 # Compare means and differences between groups. Beware: This model takes *really* long ... E3 <- fSRM(neg ~ actor.id*partner.id | family.id, data=two.groups, group="group", means=TRUE, diff=TRUE) E3 ## End(Not run)
This graphical users interface (GUI) can be used for inserting .csv, .txt and .sav-files in R by means of a pop-up window. It also allows to transform a dataset from wide into the requiered long format for the fSRM-function. The output format for the SRM components can be confirmed or modified.
import()
import()
This GUI allows the user three different things:
(i) Import a datafile in R.
The upper section of the main window allows to insert .csv, .txt and .sav-files in R. It is required that the first row of this datafile contains the variable names.
(ii) Transform a dataset that is in wide format into the desired long format, in order to use the fSRM
-function.
A new pop-up window appears after clicking on 'transform my data' in the middle section. This new window allows to transform a dataset from wide format (i.e. each column represents one measured relationship, each row one family) to the necessary long format. Specify - if present - first the variable names which identifies the different families and groups, respectively.
Next, specify the columns in the original dataset which contain the dyadic measurements. Enumerated columns need to be separated with a comma, consecutive columns need to be defined by means of colon (e.g. 1 : 9 defines the first until the second column in the original dataset).
Finally, define the position of the characters of the rater, the person being rated and the indicator (if present) in the previously selected dyadic measurements.
(iii) Define the desired output-format for the different SRM-components.
At the bottom section of the main window the user can agree with the default labels of the SRM components by clicking on 'Confirm output format' or specify alternative labels.
Importing a data set is a two-step process. First, you have to call the import
function. When you click on OK, the transformed data set is saved in a hidden variable. To access the variable, you have to call getImport
.
## Not run: import() # --> now click throught the menu dat <- getImport() ## End(Not run)
## Not run: import() # --> now click throught the menu dat <- getImport() ## End(Not run)
Get modification indices for a fSRM object.
mod(x, minMI = 10)
mod(x, minMI = 10)
x |
A fSRM object. |
minMI |
Minimum size of modification indices to be printed. |
This function provides two types of plots:
1) Plot the relative variances of an fSRM-object (default)
2) Plot the mean decomposition for each dyad (set means=TRUE
)
## S3 method for class 'fSRM' plot(x, ..., means = FALSE, bw = FALSE, onlyStable = FALSE)
## S3 method for class 'fSRM' plot(x, ..., means = FALSE, bw = FALSE, onlyStable = FALSE)
x |
A fSRM object. |
... |
Other parameters (currently not used) |
means |
If FALSE, the relative variances are plotted. If TRUE, the mean structure is plotted. |
bw |
Black/white plotting? |
onlyStable |
In case of variance plots: Should only the partitioning of the stable variance (without error) be plotted? |
## Not run: data(two.indicators) # 4 persons, 1 indicator f4.1 <- fSRM(dep1 ~ actor.id*partner.id | family.id, two.indicators, means=TRUE) f4.1 plot(f4.1) plot(f4.1, bw=TRUE) plot(f4.1, means=TRUE) # 4 persons, 2 indicators f4.2 <- fSRM(dep1/dep2 ~ actor.id*partner.id | family.id, two.indicators, means=TRUE) f4.2 plot(f4.2) plot(f4.2, bw=TRUE) plot(f4.2, means=TRUE) ## End(Not run)
## Not run: data(two.indicators) # 4 persons, 1 indicator f4.1 <- fSRM(dep1 ~ actor.id*partner.id | family.id, two.indicators, means=TRUE) f4.1 plot(f4.1) plot(f4.1, bw=TRUE) plot(f4.1, means=TRUE) # 4 persons, 2 indicators f4.2 <- fSRM(dep1/dep2 ~ actor.id*partner.id | family.id, two.indicators, means=TRUE) f4.2 plot(f4.2) plot(f4.2, bw=TRUE) plot(f4.2, means=TRUE) ## End(Not run)
Predict new cases based on a fitted fSRM model
## S3 method for class 'fSRM' predict(object, newdata, ...)
## S3 method for class 'fSRM' predict(object, newdata, ...)
object |
A fSRM object. |
newdata |
A data frame with exactly the same structure as the data frame on which the original fSRM object is based on. |
... |
Other parameters (currently not used) |
The classic Cook (2000) dataset consists of measurements on security of attachment within families. Only the variable measuring fear of rejection in family relationships is included in this dataset. Cook (2000) deduced this variable from the anxiety dimension of the adult attachment scale (Collins & Read, 1990). The orignial data consisted of four person families (i.e. two parents and two children), but in order to obtain a three person family the oldest sibling is systematically deleted in accordance with Kenny, Kashy & Cook (2006). The following labels are used for the three roles: the mother is labelled "m", the father "f" and the youngest child "y". The data are presented in the long format. Three roles are present: Mothers "m", fathers "f", and the younger child "y".
A data frame with 1249 rows and 5 variables (208 families with 3 members each, round-robin design)
The variables are as follows:
family.id An indicator for the family.
actor.id An indicator of the rater in the dyad, either "m", "f", or "y"
partner.id An indicator for the person being rated in the dyad, either "m", "f", or "y"
anx1: First indicator of relationship specific anxiety (i.e. average of first halve of the scale).
anx2: Second indicator of relationship specific anxiety (i.e. average of second halve of the scale).
This dataset was retrieved from http://davidakenny.net/kkc/c9/c9.htm in wide format and converted to an R dataset in long format.
Cook, W. L. (2000). Understanding attachment security in family context. Journal of Personality and Social Psychology, 78, 285-294. doi:10.1037/0022-3514.78.2.285
Collins, N. L., & Read, S. J. (1990). Adult attachment, working models, and relationship quality in dating couples. Journal of Personality and Social Psychology, 58, 644-663.
data(three.person) head(three.person)
data(three.person) head(three.person)
two.groups.wide
.The variables are as follows:
data(two.groups)
data(two.groups)
A data frame with 3276 rows and 6 variables (273 families with 4 members each, round-robin design)
family.id An indicator for the family.
actor.id An indicator for the perceiver, either "M", "F", "T", or "S".
partner.id An indicator for the target, either "M", "F", "T", or "S".
group An indicator for the group, 1 represents the problematic families and 2 the nonproblematic families.
neg Negativity measure.
Eichelsheim, V. I., Buist, K. L., Dekovic, M., Cook, W. L., Manders, W., Branje, S. J. T., et al. (2011). Negativity in problematic and nonproblematic families: A multigroup social relations model analysis with structured means. Journal of Family Psychology, 25, 152-6. DOI: 10.1037/a0022450.
The variables are as follows:
A data frame with 2496 rows and 4 variables (208 families with 4 members each, round-robin design)
family.id An indicator for the family.
actor.id An indicator for the perceiver, either "m", "f", "c", or "y".
partner.id An indicator for the target, either "m", "f", "c", or "y".
dep1 first measurement of attachment dependency.
dep2 second measurement of attachment dependency.
Cook, W. L. (2000). Understanding attachment security in family context. Journal of Personality and Social Psychology, 78, 285-294. doi:10.1037/0022-3514.78.2.285
data(two.indicators) head(two.indicators)
data(two.indicators) head(two.indicators)
Rerun a fSRM model with new parameters
## S3 method for class 'fSRM' update(object, evaluate = TRUE, ...)
## S3 method for class 'fSRM' update(object, evaluate = TRUE, ...)
object |
A fSRM object. |
evaluate |
Set to TRUE. |
... |
Other parameters (currently not used) |