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 enumThe initialization method for the model.static final classStores 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 TypeMethodDescriptionbooleancontainsParameter(Edge edge) containsParameter.getCoefficientRange(Node a, Node b) getCoefficientRange.getCovarianceRange(Node a, Node b) getCovarianceRange.doublegetEdgeCoef(Node a, Node b) Getter for the fieldedgeCoef.doublegetErrorCovariance(Node a, Node b) getErrorCovariance.getErrorNodes.doublegetErrorVariance(Node error) getErrorVariance.Getter for the fieldimplCovar.Getter for the fieldimplCovarMeas.The list of measured nodes for the semPm.getParameterRange(Edge edge) getParameterRange.doublegetParameterValue(Edge edge) getParameterValue.intGetter for the fieldsampleSize.getSemPm()Getter for the fieldsemPm.getVariableNodes.double[]means()means.static StandardizedSemImGenerates a simple exemplar of this class to test serialization.booleansetEdgeCoefficient(Node a, Node b, double coef) Sets the coefficient for the a->b edge to the given coefficient, if within range.booleansetErrorCovariance(Node a, Node b, double covar) Sets the covariance for the a<->b edge to the given covariance, if within range.voidsetParameterValue(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- aParametersobject
-
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- aParametersobject
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization.- Returns:
- a
StandardizedSemImobject
-
getSampleSize
public int getSampleSize()Getter for the field
sampleSize.- Returns:
- a int
-
containsParameter
containsParameter.
- Parameters:
edge- aEdgeobject- Returns:
- a boolean
-
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
Getter for the field
edgeCoef.- Parameters:
a- a->bb- a->b- Returns:
- The coefficient for a->b.
-
getErrorCovariance
getErrorCovariance.
- Parameters:
a- a->bb- a->b- Returns:
- The coefficient for a->b.
-
getParameterValue
getParameterValue.
- Parameters:
edge- aEdgeobject- Returns:
- a double
-
setParameterValue
setParameterValue.
- Parameters:
edge- aEdgeobjectvalue- a double
-
getCoefficientRange
getCoefficientRange.
- Parameters:
a- aNodeobjectb- aNodeobject- Returns:
- a
StandardizedSemIm.ParameterRangeobject
-
getCovarianceRange
getCovarianceRange.
- Parameters:
a- aNodeobjectb- aNodeobject- Returns:
- a
StandardizedSemIm.ParameterRangeobject
-
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
toString.
-
getVariableNodes
getVariableNodes.
- Returns:
- the list of variable nodes of the model, in order.
-
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:
simulateDatain 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
simulateDataReducedForm.
- Parameters:
sampleSize- a intlatentDataSaved- a boolean- Returns:
- a
DataSetobject
-
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
The list of measured nodes for the semPm. (Unmodifiable.)- Returns:
- a
Listobject
-
getErrorNodes
getErrorNodes.
- Returns:
- a
Listobject
-
getSemPm
Getter for the field
semPm.- Returns:
- a copy of the SEM PM.
-