One Sample, one sided T-test

Hello people,

I am new in R and for my class, I am trying to write the codes for one sample, a one-sided t-test for the alternative B<0. As you probably can understand, weight is the independent variable I want to test.
I wrote:

t.test(Data$weight, alternative = "less", mu = 0, paired = FALSE, var.equal = FALSE)

For some mistake I did, I am receiving a p value=1 where it is certainly should be 0.1.

I know I can find the p-value from the two-sided test but I want to be able to do it this way.
Would you please point out my mistake or suggest a fix, a better option?

I suspect it may be that you cannot have a negative weight.

I would like to test the coefficients to check the significance of the independent variable. But I think this is the wrong test for that.

I think you need to give us some background on what you are doing and some sample data.

See a reproducible example (reprex)

A handy way to supply sample data is to use the dput() function. See ?dput. If you have a very large data set then something like head(dput(myfile), 100) will likely supply enough data for us to work with.

t.test(Data$weight, alternative = "less", mu=0)

should work. Not sure why it is not, though the paired or not paired and var.equal flags are irrelevant to a one-sample t.test.

I just put them down just in case but I guess this specific test is about testing the mean of the independent variable rather than its coefficient and significance. That is what I have been told. Thank you.

If this answers the specific question that you posed, for the good of the community, you could choose an answer and close the thread.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.