[R] calculating t-score/t-stats as my zscores
Rui Barradas
ru|pb@rr@d@@ @end|ng |rom @@po@pt
Wed May 6 16:54:43 CEST 2020
Hello,
You can write a function to compute the scores:
z_score <- function(x, beta = mean, beta0 = 0){
beta <- match.fun(beta)
n <- length(x)
score <- sqrt(n)*(beta(x) - beta0)/sd(x)
names(score) <- if(n < 30) "t.score" else "z.score"
score
}
# data example
x <- rt(20, df = 1)
tt <- t.test(x)
pvals <- tt$p.value
# Now compare these 3 results and see if it answers the question
qt(pvals/2, 19, lower.tail = F)
tt$statistic
z_score(x)
Hope this helps,
Rui Barradas
Às 15:40 de 06/05/20, Ana Marija escreveu:
> I guess I can have
>
> z-score=Beta/StdErr
>
> On Wed, May 6, 2020 at 9:37 AM Ana Marija <sokovic.anamarija using gmail.com> wrote:
>>
>> thanks, can you please tell em what would be the way not to get the
>> absolute (always positive values)
>>
>> On Wed, May 6, 2020 at 9:33 AM Rui Barradas <ruipbarradas using sapo.pt> wrote:
>>>
>>> Hello,
>>>
>>> Sorry but after reading my answer I believe it's not completely clear.
>>>
>>> I meant absolute values, the actual t-scores as computed from the data
>>> might be negative. Your code will always produce positive numbers.
>>>
>>> Hope this helps,
>>>
>>> Rui Barradas
>>>
>>> Às 15:27 de 06/05/20, Rui Barradas escreveu:
>>>> Hello,
>>>>
>>>> That gives the *absolute* t-scores. If it's all you need/want, then the
>>>> answer is yes, you can.
>>>>
>>>> Hope this helps,
>>>>
>>>> Rui Barradas
>>>>
>>>> Às 14:28 de 06/05/20, Ana Marija escreveu:
>>>>> Hello,
>>>>>
>>>>> Can I apply the quantile function qt() this way?
>>>>> qt(pvals/2, 406-34, lower.tail = F)
>>>>> to get the T-scores?
>>>>>
>>>>> Thanks
>>>>> Ama
>>>>>
>>>>> ______________________________________________
>>>>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>>> PLEASE do read the posting guide
>>>>> http://www.R-project.org/posting-guide.html
>>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>>
>>>>
>>>> ______________________________________________
>>>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide
>>>> http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list