• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Files spread between Dropbox, Google Drive, Gmail, Slack, and more? Dokkio, a new product from the PBworks team, integrates and organizes them for you. Try it for free today.


February: Comments and Questions

Page history last edited by bob pruzek 9 years ago

Please use this page, and quit using the previous Comments and Questions page.


Comments (Show all 48)

Marisa Reuber said

at 9:13 pm on Feb 5, 2011

In the dep.dat function on our homework, what is the purpose of switching the order of the columns in the line xx=round(xx[,2:1],2)?

Chuck Yang said

at 10:43 pm on Feb 5, 2011

To qw315682@albany.edu: If you are referring to the dynamic graphic, I believe that you would have the option to copy the graphic into the clipboard as a metafile, then you can paste it into Word using either paste function or "Ctrl-V". If that doesn't work, you can always do a screen shot of your computer with that graphic in the front using the "Prt Sc" key (in most cases on the top right corner of your keyboard), then you can crop and resize the screen shot in Paint or any image editing software and then insert the image into Word.

I do have another question about the generated dynamic graphic using granova.2w, since we have the autonomy to rotate the graphic, what would be the principle to position the graphic so I can show as much as information or the most prominent feature of the analysis?

qw said

at 3:12 pm on Feb 6, 2011

Thanks, the "PrntScr" method works.

bob pruzek said

at 11:28 pm on Feb 5, 2011

First, Marisa: Switching the order of the columns usually results in the average difference score (red dashed line) being below the identity diagonal. Taken across many trials we have found it better to adjust to the renaming of axes than to switch from
interpretations below, then above, the identity line. If your xx data needs reversal to accomplish this, you can always input xx[,2:1].
Second, Chuck: There is no one answer to this, but if I must make just one snapshot (on a Mac we do this more easily than for pc) then I try to show as much of the data as possible, in terms of what seems to me to be most interesting. Two or three snapshots
can be helpful. b (ps. My answer re: the 3d figures would be the same as Chuck's.)

Andrey Avakov said

at 12:49 pm on Feb 6, 2011

when I try to run dep.dat function it gvies me this error
Error in mvrnorm(n, mu = c(mu1, mu2), Sigma = sigma) :
'Sigma' is not positive definite
Does that have anything to do with capitalization of Sigma?

knelder1 said

at 1:17 pm on Feb 6, 2011


When ever I run the granova.2w function I get this error message
"Error in .Internal(inherits(x, what, which)) : 'x' is missing"

I have tried looking it up online but I can not seem to find a definite answer as to why it its not working. I get alot of info about the newer R and not detecting things.

I have gone back and redone all the coding and functions up to this point and they work. I also checked them with another sample of data and I was able to get them to run with that sample of data. I am rather confused as to why its not working now.

The data is in a dataframe with the 3 rows of data response and A and B the structure indicates that they are all numbers and its not significantly different from the random sample which did work. I am running the latest R version and a 64 bit windows operating system ( I know that there have been issues in the past I really hope this is not another one of those).


bob pruzek said

at 1:30 pm on Feb 6, 2011

Andrey (first): Two things to check: Is the MASS library showing up in the R environment when you do >search( ) ? If not, do library(MASS). If yes, then go to the help
file for mvrnorm, and use the example at the end to run the function -- let me know what happens. Second, let me see your call statement (assuming yes to above) for
dep.sam so I can see what arguments you set. I'll try to replicate. You could also copy one line at a time from the dep.dat function and see what happens at each step (could
try function >debug( ) also, which can sometime lead to helpful information.

knelder1 said

at 6:33 pm on Feb 6, 2011

I was able to make it work by changing computers, something must be up with the R on my laptop. I will now be uninstalling and reinstalling it tonight to see if that fixes the issue. It worked on my father's computer which is also 64 bit so it is not a 64 bit issue.


bob pruzek said

at 1:36 pm on Feb 6, 2011

Kyrie, I think I may have to see your call statement for granova.2w . But before sending it, do this: try granova.2w(data.A.B = [[your dataframe]], data= [[your dataframe]])
AND, in a separate trial, granova.2w(Resp ~ FactA + FactB, data=[[your dataframe]]). Before doing either, you might do attach( [[your dataframe]] ) and see that search( )
shows your data (in position 2). (I'm assuming that if you do >names(your 3 col ds dataframe) after the twoCols2.3 run that your names are Resp, FactA and FactB. Edit as needed.
Also, do dim(your 3 col df) and head( same ) to ensure that these are all well; the latter should probably all be done before trying these granova.2w calls. Let us know what happens. b

qw said

at 2:07 pm on Feb 6, 2011

When I tried to run granova.2w (fit=default) and granova.2w(fit='quadratic'), I got exactly same answers, is that normal?

Andrey Avakov said

at 2:32 pm on Feb 6, 2011

professor, i've generated some data with dep.dat function
> data
[1] 0.5

[1] 9 10

[,1] [,2]
[1,] 2.83 1.70
[2,] 1.70 2.83

[,1] [,2]
[1,] 11.38 10.71
[2,] 9.80 6.16
[3,] 8.56 7.43
[4,] 10.90 8.91
[5,] 12.15 9.34
[6,] 9.36 7.42
[7,] 8.80 7.31
[8,] 8.08 8.32
[9,] 10.67 9.36
[10,] 11.22 9.12
[11,] 8.53 9.52
[12,] 11.06 11.27
[13,] 8.16 9.36
[14,] 9.51 9.73
[15,] 9.23 8.35

but when i run granova.ds(data) it says
"Input data must be a n X 2 dataframe or matrix."

qw said

at 2:44 pm on Feb 6, 2011

To Andrey: create a data frame from your generated data should then work: xx=data.frame(data$xx).

Andrey Avakov said

at 3:10 pm on Feb 6, 2011

qw, thank you very much, it worked.

bob pruzek said

at 6:03 pm on Feb 6, 2011

Qw, You asked: " When I tried to run granova.2w (fit=default) and granova.2w(fit='quadratic'), I got exactly same answers, is that normal?" Not sure what 'normal' means, but tell us what the surface looks
like in the two situations. If they are the same, and especially if the interaction effect seen in the ANOVA Summary table is 'near to null" then the quadratic surface may be virtually the same as a flat one --
and for many of you who create data using mvrnorm, there will be no (population) interaction, so the sample interaction may be near to null. Change one or two data points (e.g. data[10,2] 3*(current value) and see
how this changes things IN THE DYNAMIC PLOT. Let us know what you learn. bp

Samira said

at 8:31 pm on Feb 6, 2011

Hi. I've been trying to run the granova.2w function in R on my mac. I have version 12.11.1 of R. I first loaded granova, and granova.ds works fine. When I then try granova.2w, it loads required package rgl, then required package tcltk, then loads the Tcl/Tk interface, and does not get all the way through,well, it looks like this:

> granova.2w(xx)
Loading required package: rgl
Loading required package: tcltk
Loading Tcl/Tk interface ...
And when I try to type any further commands, I get that little pinwheel like its churning on something and I end up Force Quitting R. I tried just letting it run for a while, but it doesn't seem to be working. I also tried going on the R website to see how to get the latest version of R to see if that would change things, but I haven't figured that out yet either. Any hints?

knelder1 said

at 9:03 pm on Feb 6, 2011

This sounds alot like the issue that I was having earlier today. The only way I was able to fix it was to uninstall and reinstall R there is something in the newest version with the patches that granova.2w works after the reinstall. This is the website "http://lib.stat.cmu.edu/R/CRAN/" you would want the mac 2.12.1 version and then I would run the Professors install code that will install most of the packages you should need.


Samira said

at 10:24 pm on Feb 6, 2011

Thanks Kyrie. I uninstalled, reinstalled, and then had to add some tools, and all seems to be in order.

Chuck Yang said

at 11:06 pm on Feb 6, 2011

questions, when I tried the quadratic fit of granova.2w, I did not really see a "quadratic" look fit in R, it seems to me that the graphic looks pretty much like a linear fit still. I also get some warning messages.

Here is what I ran:

granova.2w(data.A.B=xx.25.8.6_2w, fit='quadratic', main='Granova.2w captures, Response, FactorA and FactorB (quadratic fit), BMI-Exercise Intensity Data, n=25')

Warning messages:
1: In predict.lm(mod, newdata = cbind(dat, groups = group)) :
prediction from a rank-deficient fit may be misleading
2: In predict.lm(mod, newdata = data.frame(x = 1, z = 1, groups = group)) :
prediction from a rank-deficient fit may be misleading
3: In predict.lm(mod, newdata = cbind(dat, groups = group)) :
prediction from a rank-deficient fit may be misleading
4: In predict.lm(mod, newdata = data.frame(x = 1, z = 1, groups = group)) :
prediction from a rank-deficient fit may be misleading

Help please.

bob pruzek said

at 12:37 am on Feb 7, 2011

Ignore Warnings (quite generally). Errors are one thing, and should not be ignored, but mere Warnings involve (usually arcane) technical issues that only those w/ strong technical interests will need or want to pursue.
As for the quadratic surface to be (essentially) identical to that of the linear run, that is exactly what you should expect if you have used mvrnorm to generate ds data. Real data rarely show such things however, and this
is one of the main points I want to discuss in class on Tuesday: Interactions are assumed generally to be NULL when standard ds analyses, and t-tests, are run. But you already saw that the blood lead ds graphic was NOT simple
and the granova.2w quadratic surface was HUGELY different from the flat (linear model) fit, so you can see that interaction was not only evident in the initial ds graphic, but now can be accommodated (best visually!) w/
the 2w run. If you want to modify your ds data so that interaction is evident (and a curved surface appears for the .2w run) try this: xxnew2=apply(xx2.ds, 2, FUN=function(x)1.5^x) where of course you'll have to use twoCols2.3 next, etc.
Let me/us know if you do that (and I invite you to make a small presentation in class too on Tuesday on that) ... to show what you learn! BP

Chuck Yang said

at 11:53 am on Feb 7, 2011

Dr. Pruzek, I tried to create new input data and saw quite a difference when running the granova.2w/quadratic again. But how come I see two layers of qudratic-look curve in the interactive graphic? You said I would need to use twoCols2.3 again, but I think I would already have the data in shape after the following statement, am I right:

> xx.25.8.6_new=apply(xx.25.8.6_2w, 2, FUN=function(p)1.5^p)
> granova.2w(xx.25.8.6_new, fit='quadratic')


bob pruzek said

at 12:40 am on Feb 7, 2011

Re: Mac use of X11 graphics, there is software (at oldforge) called Xcode that keeps being updated, and that you might find helpful to install on your Mac. See http://guide.macports.org/chunked/installing.xcode.html for that and follow directions there. bp

bob pruzek said

at 12:30 pm on Feb 7, 2011

Chuck, No, at least not as I'd set it up. My exact trial used xxnew2=apply(xx.15.7.5$xx,2,FUN=function(x)1.5^x)
where the first arg inside apply is a matrix output from the dep.dat run So xxnew2 has only two columns. So taking this as input to twoCols2.3 yields the 3 col version that
can be input into the .2w function. If you don't have a 3 column input the .2w function should not run at all; but if you used apply starting w/ 3 columns, I suppose that would
work. But to get what I'd intended, you need to do what I describe here. Let me know how this works for you....b

Chuck Yang said

at 9:28 pm on Feb 7, 2011

Dr. Pruzek, I tried your method and it worked. Thank you!

Manchun Chang said

at 4:37 pm on Feb 9, 2011

Dr. Pruzek,

I remember you said you will give us an article by Cumming and Finch about CI. Is it uploaded yet?

bob pruzek said

at 11:08 pm on Feb 9, 2011

Thanks for reminding me Manchun; it is now available for download, see Added2 on first p. of wiki. bp

Manchun Chang said

at 7:43 pm on Feb 13, 2011

When I run the granova.2w, I only got partial result of aov table (only df, SS, MS). But when I read the article "ElementalGraphics4ANOVA.RP+JH.pdf", the aov table report df,SS MS, F and Pr(>F) (for example, on to top of page17). How can I get the full version of aov table and what makes the output different? I tried "summary(aov(granova.2w(data.A.B=XXX)))" but received an error message.

bob pruzek said

at 9:17 pm on Feb 13, 2011

Check to see that you have the most recent version of granova. Do this by ?granova, and see if it is version 2.0. If not, then change your
mirror, and download the package again. Retry it to see if the problem occurs. All I can say is that it works fine for me in all versions. I'd
be interested to learn whether other students in the class have the same problem you're having. Let me know what happens. Best, bp

Marisa Reuber said

at 8:14 am on Feb 14, 2011

I ran into the same problem as Manchun on my last homework. When I ran the granova.2w as a linear model, I didn't get any F statistics. When I ran the granova.2w as a quadratic model, I did. I included a formula argument in the quadratic statement but not in the linear. Could this be making a difference?

Marisa Reuber said

at 8:40 am on Feb 14, 2011

When comparing two groups, if you compute the square of t to compare with the F statistic from the two way anova, F should equal t^2. What kind of interpretation should be expected from this comparison?

bob pruzek said

at 12:33 pm on Feb 14, 2011

Marisa, 1. Since I cannot reproduce what you report, there seems also to be a mac / pc difference. We need inputs from others...are you all listening?? Write. (But Manchun, I'd like to hear whether the formula input helps too.) In any case the
arithmetic is not tough! All you need to do is divide the MS(treatment) by MS(interaction) to get the F -- and this is the same as the squared t; see below.
2. The F is a unidirectional statistic, but the t is bi-directional (+ or -). Note that the critical value for t (two tailed, df matching den. of F), when squared, also gives the critical value for F. Hope this is sufficient; but in any case I'm posting a
document that summarizes the relevant distribution theory, and if you have more q.'s we can discuss them tomorrow. b

saleinna said

at 5:33 pm on Feb 14, 2011

when I input "granova.2w(filename)", I only got partial result of aov table (only df, SS, MS) as Man-chun and Marisa.
But if input "granova.2w(Response ~ FactorA + FactorB, data=filename)", I got the full table including F value and Pr(>F).
By the way, my version of granova is 2.0


Manchun Chang said

at 9:18 pm on Feb 14, 2011

My version is granova 1.3. I try several time re-downloading the package, but when I check ?granova, it still shows my version is 1.3.

I randomly check some classmates' 02/08 homeworks. The homeworks I checked all have partial aov tables.

By the way, when I upload my assignment to wiki, I click the wrong files. it seems I don't have the privilege to delete them. sorry about that.

Marisa Reuber said

at 9:49 pm on Feb 14, 2011

What is the difference between a row or column effect and a main effect?

bob pruzek said

at 11:01 pm on Feb 14, 2011

You should have version 2.0 of granova. The way to do this is first to erase all granova functions, including granova itself, from your machine ( remove as rm( each one)) and then CHANGE your MIRROR.
I use Pennsylvannia PA2 and it seems up to date. Most will be, but the one you used apparently was not. This may solve most of your granova problems. And some other students may have the same problem,
so everyone should check their version nos, and do as I asked you if not 2.0. As for deleting files, I hope I did that correctly in your case. Check to see.
Row and Col effects are MAIN effects. They must be distinguished from Row x Col (interaction) effects.
Saleinna, it appears that you have solved your problem. Good. b

Samira said

at 11:11 am on Feb 15, 2011

Two Questions on ANOVA:

1.) Can you use two way ANOVA to analyze the effects of two factors, each at only one level? Many of the examples have two or more levels per factor. What difference does the number of levels make in the interpretation besides having more detailed information?

2.) This question refers to the pdf on Chapter 7 Factorial ANOVA: Two Way ANOVA on page 7-16. Why should the sum of the effect of being at each level for all levels equal zero?

Marisa Reuber said

at 2:56 pm on Feb 15, 2011

I was able to get the bootstrap(y, nboots=1000, means4) to work by changing 'nboots' to 'nboot'.

bob pruzek said

at 2:09 pm on Feb 23, 2011

Factors in ANOVA are categorical variables generally. They MUST have at least two levels, else how could they be variables?
The 'smallest' two-way anova is a 2 x 2 design. Interpretations are illustrated in numerous places, especially in the material at Lowry's website (on-line book on ANOVA) and in my various pdfs that I have given you. Use your search engine to find numerous others. Your second question suggests you have not understood a key idea in ANOVA: that effects are differences between either group means and the grand mean, or (in the two way case) differences between row or col means and the grand mean. This is spelled out in detail in the first sections of my elemental graphics pdf. Please read that carefully. Then let us know whether it has become clear or not. bp

Matthew Swahn said

at 11:49 am on Mar 2, 2011

I have few questions:
1) When I see the standard error when I fit a model, I tend to think of it as a standard deviation of sorts for the coefficient estimate. Is it correct to do this?
2) When interpreting test statistics, do we need to keep any hypothesis in consideration, or do we let test statistics speak for themselves?

And one that might digress from the course a bit:
Usually when fitting models, the values that are listed in the r window are the estimate for the coefficient, the standard error, t statistic/f statistic, and it's corresponding p value. Instead of listing a p value, would listing a 95% confidence interval for the coefficient be a better alternative?

bob pruzek said

at 11:45 pm on Mar 2, 2011

1. 'standard deviation of sorts' is not sound language. A standard error is ALWAYS an estimated standard error, the s.d. of a hypothetical sampling distribution for the statistic. What else can I say?
2. In this course you should aim to interpret all key results, including test statistics. Each interpretation will be, at least in part, conditional on the application, including the context, main features of the data, how many variables there are, etc.
In a (published) report, one often includes only a few of the highlights, since to be expansive would take more space than is usually reasonable; moreover, audiences are presumed to know the basics. The great virtue of expanded interpretations
in courses like this one is that you can and should receive feedback on details of what you say.
And yes, it would be better to replace p-values with CIs in ANOVA tables; but the form was set at least 50 years ago and it is hard to break old habits (even when they should be broken, as in this case). Good question.

bob pruzek said

at 10:16 pm on Mar 5, 2011

Addendum for Matt: re: the conf.interval question, there is a function in the (base) stats package called confint that will construct confidence intervals for the coefficients in a linear model. Try it w/ models that use 'lm', the linear
regression workhorse package. One of the functions that uses this (among many) is aov, so you can try confint w/ objects generated w/ either aov or lm. For any of you, let us know if you tried it, and how it worked... bp

You don't have permission to comment on this page.