Skip to content

Instantly share code, notes, and snippets.

View AbeKh's full-sized avatar
🐪
I may be slow to respond.

Abraheem Khouqeer AbeKh

🐪
I may be slow to respond.
View GitHub Profile
@AbeKh
AbeKh / T Test via summary stats
Created November 27, 2023 19:32
A two sample t test fucntion to output p-value from inputs of means and standard error
t.test_SEM <- function(mean1, mean2, SE1, SE2, n1, n2) {
# Calculate t-statistic
t_statistic <- (mean1 - mean2) / sqrt(SE1^2 + SE2^2)
# Calculate degrees of freedom
df <- ((SE1^2 + SE2^2)^2) / (((SE1^2)^2 / (n1 - 1)) + ((SE2^2)^2 / (n2 - 1)))
# Calculate p-value
p_value <- 2 * pt(abs(t_statistic), df = df, lower.tail = FALSE)
@AbeKh
AbeKh / PropagateError_ExcelFunction
Last active October 17, 2023 18:20
custom Excel function (also known as a User-Defined Function or UDF) to perform error propagation for multiplication or division.
'1. Press `ALT` + `F11` to open the Visual Basic for Applications (VBA) editor in Excel.
'2. In the VBA editor, click `Insert` > `Module` to insert a new module.
'3. Copy and paste the following VBA code into the module:
Function PropagateError(operation As String, value1 As Double, sigma1 As Double, value2 As Double, sigma2 As Double) As Double
Dim result As Double