Package edu.cmu.tetrad.sem
Class StandardizedSemIm
java.lang.Object
edu.cmu.tetrad.sem.StandardizedSemIm
- All Implemented Interfaces:
Simulator
,TetradSerializable
,Serializable
A special SEM model in which variances of variables are always 1 and means of variables are always 0. In order to
ensure that means of variables are always zero, means or error terms are set to zero. (They are alway Gaussian for
this model.) Connection functions are always linear. In order to ensure that variances of variables are always 1,
only coefficients are allowed to change, and the error terms take up the slack. Becuase of this constraint, given
settings of other freeParameters, the range of a given parameter is always bounded above and below. The user may
query this range and set set the value of the coefficient to anything within this range. The SEM is initialized from
a linear, gaussian SEM by calculating (or estimating) what the coefficients would be if a data set were simulated
from that SEM, standardized, and reestimated with the same SEM PM. The coefficients of such an estimated SEM PM are
used to initialize the standardized SEM, repeating if necessary (due to possible noise issues) to get coefficients
for which all errors variances can be calculated. (Variances need to be >= 0 for Normal distributions.) This
produces a set of coefficients that are viable candidates for the standardized SEM. From there, the user cannot make
any change that does not also allow for a standardized SEM to be defined, with error variances taking up the slack.
Thus, the standardized SEM can never go "out of bounds."
Currently we are not allowing bidirected edges in the SEM graph.
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
The initialization method for the model.static final class
Stores a coefficient range--i.e. -
Constructor Summary
ConstructorsConstructorDescriptionStandardizedSemIm
(SemIm im, StandardizedSemIm.Initialization initialization, Parameters parameters) Constructs a new standardized SEM IM from the freeParameters in the given SEM IM.StandardizedSemIm
(SemIm im, Parameters parameters) Constructs a new standardized SEM IM, initializing from the freeParameters in the given SEM IM. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsParameter
(Edge edge) containsParameter.getCoefficientRange
(Node a, Node b) getCoefficientRange.getCovarianceRange
(Node a, Node b) getCovarianceRange.double
getEdgeCoef
(Node a, Node b) Getter for the fieldedgeCoef
.double
getErrorCovariance
(Node a, Node b) getErrorCovariance.getErrorNodes.double
getErrorVariance
(Node error) getErrorVariance.Getter for the fieldimplCovar
.Getter for the fieldimplCovarMeas
.The list of measured nodes for the semPm.getParameterRange
(Edge edge) getParameterRange.double
getParameterValue
(Edge edge) getParameterValue.int
Getter for the fieldsampleSize
.getSemPm()
Getter for the fieldsemPm
.getVariableNodes.double[]
means()
means.static StandardizedSemIm
Generates a simple exemplar of this class to test serialization.boolean
setEdgeCoefficient
(Node a, Node b, double coef) Sets the coefficient for the a->b edge to the given coefficient, if within range.boolean
setErrorCovariance
(Node a, Node b, double covar) Sets the covariance for the a<->b edge to the given covariance, if within range.void
setParameterValue
(Edge edge, double value) setParameterValue.simulateData
(int sampleSize, boolean latentDataSaved) Simulates data from the model associated with this object.simulateDataReducedForm
(int sampleSize, boolean latentDataSaved) simulateDataReducedForm.toString()
toString.
-
Constructor Details
-
StandardizedSemIm
Constructs a new standardized SEM IM, initializing from the freeParameters in the given SEM IM.- Parameters:
im
- The SEM IM that the freeParameters will be initialized from.parameters
- aParameters
object
-
StandardizedSemIm
public StandardizedSemIm(SemIm im, StandardizedSemIm.Initialization initialization, Parameters parameters) Constructs a new standardized SEM IM from the freeParameters in the given SEM IM.- Parameters:
im
- Stop asking me for these things! The given SEM IM!!!initialization
- CALCULATE_FROM_SEM if the initial values will be calculated from the given SEM IM;parameters
- aParameters
object
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization.- Returns:
- a
StandardizedSemIm
object
-
getSampleSize
public int getSampleSize()Getter for the field
sampleSize
.- Returns:
- a int
-
containsParameter
-
setEdgeCoefficient
Sets the coefficient for the a->b edge to the given coefficient, if within range. Otherwise does nothing.- Parameters:
a
- a -> bb
- a -> bcoef
- The coefficient of a -> b.- Returns:
- true if the coefficent was set (i.e. was within range), false if not.
-
setErrorCovariance
Sets the covariance for the a<->b edge to the given covariance, if within range. Otherwise does nothing.- Parameters:
a
- a <-> bb
- a <-> bcovar
- The covariance of a <-> b.- Returns:
- true if the coefficent was set (i.e. was within range), false if not.
-
getEdgeCoef
-
getErrorCovariance
-
getParameterValue
-
setParameterValue
-
getCoefficientRange
getCoefficientRange.
- Parameters:
a
- aNode
objectb
- aNode
object- Returns:
- a
StandardizedSemIm.ParameterRange
object
-
getCovarianceRange
getCovarianceRange.
- Parameters:
a
- aNode
objectb
- aNode
object- Returns:
- a
StandardizedSemIm.ParameterRange
object
-
getParameterRange
getParameterRange.
- Parameters:
edge
- a->b or a<->b.- Returns:
- the range of the covariance parameter for a->b or a<->b.
-
getErrorVariance
getErrorVariance.
- Parameters:
error
- The error term. A node with NodeType.ERROR.- Returns:
- the error variance for the given error term. THIS IS NOT A PARAMETER OF THE MODEL! Its value is simply calculated from the given coefficients of the model. Returns Double.NaN if the error variance cannot be computed.
-
toString
-
getVariableNodes
-
means
public double[] means()means.
- Returns:
- For compatibility only. Returns the variable means of the model. These are always zero, since this is a standardized model. THESE ARE ALSO NOT PARAMETERS OF THE MODEL. ONLY THE COEFFICIENTS ARE PARAMETERS.
-
simulateData
Simulates data from the model associated with this object.A convenience method, in case we want to change out mind about how to simulate. For instance, it's unclear yet whether we can allow nongaussian errors, so we don't know yet whether the reduced form method is needed.
- Specified by:
simulateData
in interfaceSimulator
- Parameters:
sampleSize
- the number of rows to simulate.latentDataSaved
- if true, latent variables are saved in the data set.- Returns:
- the simulated data set.
-
simulateDataReducedForm
-
getImplCovar
Getter for the field
implCovar
.- Returns:
- a copy of the implied covariance matrix over all the variables.
-
getImplCovarMeas
Getter for the field
implCovarMeas
.- Returns:
- a copy of the implied covariance matrix over the measured variables only.
-
getMeasuredNodes
-
getErrorNodes
-
getSemPm
-