readxl::read_excel(here("PIG PAUS data_yc.xlsx")) %>% janitor::clean_names() |> janitor::remove_empty() |>mutate(measurement_value =as.numeric(measurement_value)) ->df
value for "which" not specified, defaulting to c("rows", "cols")
Warning: There was 1 warning in `mutate()`.
ℹ In argument: `measurement_value =
as.numeric(measurement_value)`.
Caused by warning:
! NAs introduced by coercion
Analysis
df |>group_by(pig, treated, wavelength) |>summarise(mean =mean(measurement_value, na.rm=TRUE), sd =sd(measurement_value, na.rm=TRUE)) |>gt() |>tab_header(title =md("Data Grouped by Pig, Treatment, and Wavelength") )
`summarise()` has grouped output by 'pig', 'treated'. You
can override using the `.groups` argument.
Data Grouped by Pig, Treatment, and Wavelength
wavelength
mean
sd
PAPC-1 - 0
800
4283.677
423.8885
1200
3634.495
301.0695
PAPC-1 - 1
800
6255.793
203.0605
1200
5340.887
573.8289
PAPC-3 - 0
750
4633.550
143.4739
800
4625.280
309.0905
1200
3810.645
528.7532
1310
3709.348
535.2551
PAPC-3 - 1
800
6751.210
450.3719
1200
6448.237
622.0233
1310
5500.300
121.5375
df |>group_by(treated, wavelength) |>summarise(mean =mean(measurement_value, na.rm=TRUE), sd =sd(measurement_value, na.rm=TRUE)) |>gt() |>tab_header(title =md("Data Grouped by Treatment (0/1) and Wavelength") )
`summarise()` has grouped output by 'treated'. You can
override using the `.groups` argument.
Data Grouped by Treatment (0/1) and Wavelength
wavelength
mean
sd
0
750
4633.550
143.4739
800
4369.078
408.6534
1200
3678.533
333.6674
1310
3709.348
535.2551
1
800
6503.502
413.8341
1200
5894.562
808.9155
1310
5500.300
121.5375
We can perform unpaired t tests without regard to pig or esophageal location
Even with this small N, there is some variance from pig to pig at 800 nm. There is a trend toward higher values for Pig 3. There is a significant difference between treated and untreated pigs. Treatment increases signal at 800 nm by ~ 2020 AU. There is minimal difference between the different esophageal sites (with this small N). We are not controlling for pig age, which might correlate with higher signals.
model <-lm(measurement_value ~ pig + treated + site_cm, data = df |>filter(wavelength ==1200))model |> broom::tidy()
Even with this small N, there is some variance from pig to pig at 1200 nm. There is a trend toward higher values for Pig 3. There is a significant difference between treated and untreated pigs. Treatment increases signal at 1200 nm by ~ 2078 AU. There is minimal difference between the different esophageal sites (with this small N). We are not controlling for pig age, which might correlate with higher signals.
model <-lm(measurement_value ~ treated + site_cm, data = df |>filter(wavelength ==1310))model |> broom::tidy()
Only one pig was evaluated at 1310 nm. There is a significant difference between treated and untreated pigs.Treatment increases signal at 1310 nm by ~ 1857 AU. There is minimal difference between the different esophageal sites (with this small N). We are not controlling for pig age, which might correlate with higher signals.
Let’s look at paired t-tests - in the same pig at the same site.
Now let’s perform the paired t-test at 800 nm - in two ways, first by looking at the differences in the same pig at the same site, then by using the official paired t test.
Now let’s perform the paired t-test at 1200 nm - in two ways, first by looking at the differences in the same pig at the same site, then by using the official paired t test.