Title | SYNTAX FOR STATA USE |
---|---|
Author | Ainsley Lazarus |
Course | Design and Statistics II |
Institution | Macquarie University |
Pages | 3 |
File Size | 121 KB |
File Type | |
Total Downloads | 78 |
Total Views | 142 |
This is a detailed syntax for stata commands. Table form makes it easy to use during the exam or while analysing data....
Syntax ANOVA DV IVlistf
Test/analysis One-way ANOVA
Notes Includes variance of group means and total variation.
ANOVA DV Ivlist IV1#IV2
Factorial ANOVA: main effects Observe main effects & interactions & interaction
ANOVA DV IV1#IV2
Factorial Anova interaction
by BYvars: summarize VARlist codebook VARlist
Comparing outputs
descriptives
produces summary data for variable list stratified by levels of categories
additional information
gives you range min max missing values mean sd and percentiles
contrast {VARcat weights…} {VARcat weights...}, effects complex contrasts
Testing main effects and interaction effects
contrast p.VARcat
Polynomial contrasts
Tests linear, quadratic, cubic trends
Reference contrasts
Testing difference in estimated cell means, e.g. gender
contrast r.VARcat correlate VARlist correlate VARlist, covariance
estat vif
Frequency VARlist
correlation matrix
Compute correlations between variables
covariance matrix
Computes the sample covariances between variables
Descriptives for VIF collinearity
Run after regress. Shows VIF and tolerance for each IV. VIF should be < 10, tolerance > 0.1f
frequency table
Summary statistics for categorical & continuous variables
Graph bar (count), over(VAR)
Generating bar graph of variables
Usually used for categorical data
graph bar (count), over(VAR) over(VAR) asyvars
Coloured graph bar with frequencies
(count) gives frequencies rather than % Asyvars is colour
Draws vertical bar charts
Here (percept) gives you % rather than frequencies
Clustered bar chart
Create clustered bar chart to illustrate the two way ANOVA with predicted values.t
Pie Chart
Used for categorical data to see proportions of participants (percentage distribution)
graph twoway (scatter VARlist) (lfit VARlist), ytitle ("IV”)
Two-way scatterplot graph
Used to see variance!
histogram VAR, by(groupVAR), freq
Histogram of a variable
graph bar (percent), over(VAR) graph bar yhat, over(IV1) over(IV2) asyvars ytitle("Predicted Cell Means for DV”) graph pie, over(VAR)
Can be used to see central tendency
Data features
histogram, no. of pos/0/neg. intergers/nonintergers, missing data
margins VARcat
Marginal means
displays group means
margins VARcat, at(VARcont(values))
Computes the predicted values for each specified case (designated by at)
inspect VARlist
marginsplot
Plot of marginal means
pnorm VARlist
Standardised normal probability plot
predict dfbetaVARname, dfbeta(VARname)
Influence statistics
predict RESNAME, resid predict YpredVARname pwcompare VARcat, effects mcompare(DECISION RULE) pwcorr VARlist, sig obs
regress DV IV
regress DV IVlist
Regression - testing assumptions
MUST follow 'margins' command as it plots the result of this command
this creates a new variable with values of your residuals
Creates predictions for This must follow the regression you want to sample in which model was fit test
Pairwise contrasts
Pairwise comparison contrasts & 'mcompare' adjusts contrasts using chosen decision rule E.g Scheffe, Bonferroni
Pairwise sample correlations selects cases pairwise (rather than the default matrix listwise) for analysis
Simple regression
Runs a linear regression. First put in DV followed by the IV
Multiple regression
Runs a linear regression with more IV's (if applicable) after the DV
regress DV Ivlist, beta
Display beta regression coefficients value (0.0 - 1.0) instead of CI95% as z-scores so the effects are comparable (which IV has more effect on Beta (standardised) rather than confidence the DV) intervals
robvar VAR, by(groupVAR)
Levene’s test of equality of variance: homoscedasticity
rvfplot
Residual-versus-fitted scores Plots residuals (of observations) against the plot regression line
rvpplot
looks for violations of the regression assumptions – If assumptions are correct, Residual-versus-predictor plot there should be NO pattern on the graph
scatter DV Ypred IVlist
we want the P value to be more than .05: the variability is not significantly different
Observed vs. predicted values Formation of scatterplot
scatter RESNAME IVlist
Scatterplot with residual
scatter RESNAME Ypred
Scatterplot with line of best fit Also shows predicted values
Summarize VARlist
See summary information for the variables Basic descriptives of variables listed
Summarize VARlist, detail
Detailed Descriptives
Descriptives with skew, kurtosis, etc
swilk VARlist
shapiro wilk test of normality
we want the P value to be more than .05
tab VARlist
contingency table
tab VARlist, exact
independence test without distribution convergence assumption
tab VARlist, row expected chi2
chi-square test with freq, %, expected
be careful- computationally difficult to compute- if there is a lot of data
frequency tabulation
Shows categorical variables in frequencies and percentages
2-factor contingency table
creates 2-factor contingency tables for all combinations of variations in VAR list
table IVlist, contents (n DV mean DV sd DV) row col format(%6.2f)
Used to find the cell and marginal means of factorial anova
Gives n, mean and SD of each Iv * IV combination
format(%6.2f)
The output will show 6 figures and round of to 2 decimal places (??) Set variables’ output format (fixed)???
tab1 VARlist tab2 VARlist
tabulate VARlist tabulate IVlist, summarize (DV)
ttest DV, by(IV)
Same as tab1 varlist
Shows categorical variables in frequencies and percentages
Summarise mean, SD and Freq for the variables t-test between two groups (between subject) Gives you t-statistic for your DV by the IV
ttest VAR == testVALUE
One-sample t test and Twosample t test using groups
ttest VAR1 = VAR2
Two-sample t test using variables and Paired t test
twoway scatter DV IV
Scatterplot between two variables
Scatterplot showing the DV and IV (with no line of best fit)
twoway scatter DV IV || lfit DV IV
Scatterplot with linear prediction added
Scatterplot with line of best fit
webuse FILE
Scatterplot with linear prediction added
access data file on server
webuse set URL
Scatterplot with linear prediction added
access server holding data...