mxFitFunctionWLS {OpenMx}R Documentation

Create MxFitFunctionWLS Object

Description

This function creates a new MxFitFunctionWLS object.

Usage

mxFitFunctionWLS(weights = "ULS")

Arguments

weights

Ignored. Uses weights from mxData

Details

Fit functions are functions for which free parameter values are optimized such that the value of a cost function is minimized. The mxFitFunctionWLS function computes the weighted least squares difference between the data and the model-implied expectations for the data based on the free parameters and the expectation function (e.g., mxExpectationNormal or mxExpectationRAM) selected for the model.

The 'weights' argument is ignored. Rather the weights are provided in the mxData object, often generated by the mxDataWLS function.

Usage Notes:

The results of the optimization can be reported using the summary function, or accessed directly in the 'output' slot of the resulting model (i.e., modelName$output). Components of the output may be referenced using the Extract functionality.

Value

Returns a new MxFitFunctionWLS object. One and only one MxFitFunctionWLS object should be included in each model along with an associated mxExpectationNormal or mxExpectationRAM object.

References

The OpenMx User's guide can be found at http://openmx.ssri.psu.edu/documentation.

See Also

Other fit functions: mxFitFunctionMultigroup, mxFitFunctionML, mxFitFunctionAlgebra, mxFitFunctionGREML, mxFitFunctionR, mxFitFunctionRow

More information about the OpenMx package may be found here.

Examples


# Create and fit a model using mxMatrix, mxAlgebra, mxExpectationNormal, and mxFitFunctionWLS

library(OpenMx)

# Simulate some data

x=rnorm(1000, mean=0, sd=1)
y= 0.5*x + rnorm(1000, mean=0, sd=1)
tmpFrame <- data.frame(x, y)
tmpNames <- names(tmpFrame)
wdata <- mxDataWLS(tmpFrame)

# Define the matrices


S <- mxMatrix(type = "Full", nrow = 2, ncol = 2, values=c(1,0,0,1), 
              free=c(TRUE,FALSE,FALSE,TRUE), labels=c("Vx", NA, NA, "Vy"), name = "S")
A <- mxMatrix(type = "Full", nrow = 2, ncol = 2, values=c(0,1,0,0), 
              free=c(FALSE,TRUE,FALSE,FALSE), labels=c(NA, "b", NA, NA), name = "A")
I <- mxMatrix(type="Iden", nrow=2, ncol=2, name="I")

# Define the expectation

expCov <- mxAlgebra(solve(I-A) %*% S %*% t(solve(I-A)), name="expCov")
expFunction <- mxExpectationNormal(covariance="expCov", dimnames=tmpNames)

# Choose a fit function

fitFunction <- mxFitFunctionWLS()

# Define the model

tmpModel <- mxModel(model="exampleModel", S, A, I, expCov, expFunction, fitFunction, 
                    wdata)

# Fit the model and print a summary

tmpModelOut <- mxRun(tmpModel)
summary(tmpModelOut)


[Package OpenMx version 2.7.9 Index]