cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
thuptimd
Level I

Help : How does JMP calculate Std Error for Least Squares Means?

Hi all,

   I'm having tough times understanding how JMP generates std error in the least squares means table. 

 

I have a model with two effects ie. factor 1 (3 categories) and factor 2 (2 categories)

>> y = intercept+ factor 1 + factor 2.

 

According to JMP, I'm able to get the LS mean of factor 1 by calculating the mean of predicted values.   

 

However, I couldn't get the Std Error that JMP reported when I used the same approach with Std Error (ie. calculate the Std Error of predicted values).

 

In JMP's manual, it has described that Std Error of LS mean shows the standard error of the least squares mean for each level. 

 

I may interpret this wrong.  Can someone please help clarify what this means?

 

ps. I attached my model in the picture. To give an example of how I calculate a predicted value for

Task = N-back, Diagnosis = Non-SCD

I calculated y = 0.229-0.072+0.0662.

LS mean example.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
peng_liu
Staff

Re: Help : How does JMP calculate Std Error for Least Squares Means?

What you recently provided is a different analysis from the one in your original post. The new one is more complex. Also you still have not found the "Parameter Estimates" report. I change my strategy to explain.

Run the following codes to get an example data and a Least Squares analysis.

 

dt = New Table( "sample",
	Add Rows( 24 ),
	New Column( "X1",Character,Nominal,Set Values( {"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B"} ),	),
	New Column( "X2",Character,Nominal,Set Values( {"x", "x", "x", "x", "y", "y", "y", "y", "z", "z", "z", "z", "x", "x", "x", "x", "y", "y", "y", "y", "z", "z", "z", "z"} ),	),
	New Column( "Y",Numeric,Continuous,Set Values([18.33, 10.21, -2, -14.02, -21.37, -32.28, -36.99, -46.6, -56.95, -66.74, -75.84, -83, -74.18, -64.9, -55.96, -47.03, -36.72, -26.27,-18.1, -11.28, -2.18, 6.84, 16.51, 24.81]),	)
);
dt << Fit Model( Y( :Y ), Effects( :X1, :X2 ), Personality( "Standard Least Squares" ), Emphasis( "Effect Screening" ), Run );

And here are "Parameter Estimates" and "Correlation of Estimates", the prediction expression, and LS Means of X1:

peng_liu_1-1610389019999.png

peng_liu_2-1610389055423.png

peng_liu_3-1610389108529.png

peng_liu_5-1610389787443.png

The prediction expression gives one some idea about the mathematical expression of the model, but not quite exact. The model looks like this

peng_liu_4-1610389638467.png

In which, b0 = -28.98792, b1 = -4.949583, b2 = 0.2941667, b3 = 0.286667, from the Parameter Estimates report.

The LS Mean of A is calculated by letting X1 = 1, X2 = 0, and X3 = 0 in the model. And three values plus the intercept form the x-vector in the following codes. Each element is the partial derivative of your prediction formula (a function of estimates) with respect to the corresponding parameter.

The following code calculates Std Error for LS Mean of A.

x = [1 1 0 0];
s = diag([7.034044 7.034044 9.94764 9.94764]);
R = [1 0 0 0,
	0 1 0 0,
	0 0 1 -0.5,
	0 0 -0.5 1];
sqrt(x * s * R * s * transpose(x));

The values in "s" is from the Std Error column in the "Parameter Estimates". The matrix "R" is from the Correlation of Estimates. The product of "s*R*s" gives the covariance matrix of estimates. The product of "x*s*R*s*transpose(x)" gives the variance estimate of your prediction. The square root of the variance estimate give std error.

All other std errors are calculated similarly by using different x-vectors. E.g for B, x = [1 -1 0 0].

 

 

Now I explain the plot. It is supposed to depict estimated LS means and their 95% confidence intervals. In theory, under the model assumption, the ratio of the LS mean estimate and the corresponding Std Error, follows a t-distribution with the degree of freedom that equals to the degree of freedom of the model, which is the total number of observations minus the number of parameters. Therefore, the confidence interval for LS means has the formula that I mentioned.

 

Now I explain why Std Errors are same. This is due to the characteristics in the data. The data that I am giving here is from a balanced design, or equal number of observations in different levels in another word. Try to delete a couple of rows from one level, and you should see unequal std errors.

 

Your latest analysis is more complex and involves random effect. But the principle of the explanation still applies.

 

------------

The post is updated with a correction to x-vector for LS Mean of B.

View solution in original post

6 REPLIES 6
peng_liu
Staff

Re: Help : How does JMP calculate Std Error for Least Squares Means?

Are you trying to calculate the standard error of y = 0.229-0.072+0.0662?

Then none of the numbers in your screenshot give you that. Those means are marginal, e.g. mean of N-back is simply the mean of your Y of all observations whose Task = N-back, regardless what Diagnosis  is.

To find std err of your prediction, try Estimates > Custom Test. 

thuptimd
Level I

Re: Help : How does JMP calculate Std Error for Least Squares Means?

Hi peng_liu,

    Thank you for your response. I'm trying to replicate the LS mean plot.  I want to plot the LSmean +- Std Error.  I want to understand what Std Error in the LS mean table represents and how JMP gets these values.

 

 

Thank you,

 

peng_liu
Staff

Re: Help : How does JMP calculate Std Error for Least Squares Means?

You need two more pieces to reconstruct the numbers. They are (1) Parameter Estimate report (2) Correlation of Estimates report. The first is available by default. You need to turn on Estimates > Correlation of Estimates to see the second one. Please post their screenshots here, so it would be easier for me to explain.

Other than that, the plot is not LSmean +/- Std Err. It is LSmean +/- T Quantile(.975, df) * Std Err. How many observations do you have?

thuptimd
Level I

Re: Help : How does JMP calculate Std Error for Least Squares Means?

Hi peng_liu,

     Thank you for your response.  I have posted my screenshots here.  I have two groups of subjects - SCD and non-SCD, classified as Diagnosis.  I have 15 subjects in each group, so I have 30 subjects in total.  For each subject, I have 3 observations classified by Tasks.  In the table, subject id is Acrostic.

 

I construct mixed model with these effects and one covariate (Baseline BRSv)

∆PPGa = Acrostic[Random] + Tasks + Diagnosis + Diagnosis*Tasks + Baseline BRSv. 

 

I want to plot mean ∆PPGa +- Std Error for each combination for each combination of Tasks, Diagnosis after adjusting for Baseline BRSv. 

 

I figured that the LS mean plot of Diagnosis*Tasks must be what I want ;however, I don't understand why Std Error is the same for each combination (ie. in the LS mean table of Tasks*Diagnosis, all Std Error = 0.0417 )

 

Although you have pointed out that the LS mean plot is not with Std Error, 

can you please help me understand?

>how Std Error is calculated before we get into LSmean +/- T Quantile(.975, df) * Std Err. 

 

My Correlation of Estimates report is a bit messy, but it is the second page of my attachmant.

 

Thank you for your time,

 

 

 

 

 

 

 

 

I'm trying to generate a plot of my outcome (∆PPGa) in each category, 

peng_liu
Staff

Re: Help : How does JMP calculate Std Error for Least Squares Means?

What you recently provided is a different analysis from the one in your original post. The new one is more complex. Also you still have not found the "Parameter Estimates" report. I change my strategy to explain.

Run the following codes to get an example data and a Least Squares analysis.

 

dt = New Table( "sample",
	Add Rows( 24 ),
	New Column( "X1",Character,Nominal,Set Values( {"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B"} ),	),
	New Column( "X2",Character,Nominal,Set Values( {"x", "x", "x", "x", "y", "y", "y", "y", "z", "z", "z", "z", "x", "x", "x", "x", "y", "y", "y", "y", "z", "z", "z", "z"} ),	),
	New Column( "Y",Numeric,Continuous,Set Values([18.33, 10.21, -2, -14.02, -21.37, -32.28, -36.99, -46.6, -56.95, -66.74, -75.84, -83, -74.18, -64.9, -55.96, -47.03, -36.72, -26.27,-18.1, -11.28, -2.18, 6.84, 16.51, 24.81]),	)
);
dt << Fit Model( Y( :Y ), Effects( :X1, :X2 ), Personality( "Standard Least Squares" ), Emphasis( "Effect Screening" ), Run );

And here are "Parameter Estimates" and "Correlation of Estimates", the prediction expression, and LS Means of X1:

peng_liu_1-1610389019999.png

peng_liu_2-1610389055423.png

peng_liu_3-1610389108529.png

peng_liu_5-1610389787443.png

The prediction expression gives one some idea about the mathematical expression of the model, but not quite exact. The model looks like this

peng_liu_4-1610389638467.png

In which, b0 = -28.98792, b1 = -4.949583, b2 = 0.2941667, b3 = 0.286667, from the Parameter Estimates report.

The LS Mean of A is calculated by letting X1 = 1, X2 = 0, and X3 = 0 in the model. And three values plus the intercept form the x-vector in the following codes. Each element is the partial derivative of your prediction formula (a function of estimates) with respect to the corresponding parameter.

The following code calculates Std Error for LS Mean of A.

x = [1 1 0 0];
s = diag([7.034044 7.034044 9.94764 9.94764]);
R = [1 0 0 0,
	0 1 0 0,
	0 0 1 -0.5,
	0 0 -0.5 1];
sqrt(x * s * R * s * transpose(x));

The values in "s" is from the Std Error column in the "Parameter Estimates". The matrix "R" is from the Correlation of Estimates. The product of "s*R*s" gives the covariance matrix of estimates. The product of "x*s*R*s*transpose(x)" gives the variance estimate of your prediction. The square root of the variance estimate give std error.

All other std errors are calculated similarly by using different x-vectors. E.g for B, x = [1 -1 0 0].

 

 

Now I explain the plot. It is supposed to depict estimated LS means and their 95% confidence intervals. In theory, under the model assumption, the ratio of the LS mean estimate and the corresponding Std Error, follows a t-distribution with the degree of freedom that equals to the degree of freedom of the model, which is the total number of observations minus the number of parameters. Therefore, the confidence interval for LS means has the formula that I mentioned.

 

Now I explain why Std Errors are same. This is due to the characteristics in the data. The data that I am giving here is from a balanced design, or equal number of observations in different levels in another word. Try to delete a couple of rows from one level, and you should see unequal std errors.

 

Your latest analysis is more complex and involves random effect. But the principle of the explanation still applies.

 

------------

The post is updated with a correction to x-vector for LS Mean of B.

thuptimd
Level I

Re: Help : How does JMP calculate Std Error for Least Squares Means?

Hi peng_liu,

    Thank you for the thorough explanation. This is clear, and I understand now.

Really appreciate your help!

 

Best,