ages\$oddsratio = 0 for(i in 0:179) { for(j in 1:10) { a = ages\$survived[(i*10)+5] c = ages\$evdeath[(i*10)+5] if(j == 5) { ages\$oddsratio[(i*10)+j] = 1.00 next } b = ages\$survived[(i*10)+j] d = ages\$evdeath[(i*10)+j] ages\$oddsratio[(i*10)+j] = (a * d) / (b * c) } } # subset to just look at slopes of each line and verify they aren't zero # or the same, I guess age1sub <- subset(ages, AGE == "9 and Under" & !is.na(oddsratio) & !is.infinite(oddsratio)) age2sub <- subset(ages, AGE == "10-19" & !is.na(oddsratio) & !is.infinite(oddsratio)) age3sub <- subset(ages, AGE == "20-29" & !is.na(oddsratio) & !is.infinite(oddsratio)) age4sub <- subset(ages, AGE == "40-49" & !is.na(oddsratio) & !is.infinite(oddsratio)) age5sub <- subset(ages, AGE == "50-59" & !is.na(oddsratio) & !is.infinite(oddsratio)) age6sub <- subset(ages, AGE == "60-69" & !is.na(oddsratio) & !is.infinite(oddsratio)) age7sub <- subset(ages, AGE == "70-79" & !is.na(oddsratio) & !is.infinite(oddsratio)) age8sub <- subset(ages, AGE == "80-89" & !is.na(oddsratio) & !is.infinite(oddsratio)) age9sub <- subset(ages, AGE == "90+" & !is.na(oddsratio) & !is.infinite(oddsratio)) modelage1 <- lm(oddsratio ~ t, data=age1sub) modelage2 <- lm(oddsratio ~ t, data=age2sub) modelage3 <- lm(oddsratio ~ t, data=age3sub) modelage4 <- lm(oddsratio ~ t, data=age4sub) modelage5 <- lm(oddsratio ~ t, data=age5sub) modelage6 <- lm(oddsratio ~ t, data=age6sub) modelage7 <- lm(oddsratio ~ t, data=age7sub) modelage8 <- lm(oddsratio ~ t, data=age8sub) modelage9 <- lm(oddsratio ~ t, data=age9sub) races\$oddsratio = 0 for(i in 0:179) { for(j in 1:6) { a = races\$survived[(i*6)+4] c = races\$evdeath[(i*6)+4] if(j == 4) { races\$oddsratio[(i*6)+j] = 1.00 next } b = races\$survived[(i*6)+j] d = races\$evdeath[(i*6)+j] races\$oddsratio[(i*6)+j] = (a * d) / (b * c) } } aiansub <- subset(races, RACE == "AIAN" & !is.na(oddsratio) & !is.infinite(oddsratio)) asnsub <- subset(races, RACE == "ASN" & !is.na(oddsratio) & !is.infinite(oddsratio)) blksub <- subset(races, RACE == "BLK" & !is.na(oddsratio) & !is.infinite(oddsratio)) mltothsub <- subset(races, RACE == "MLTOTH" & !is.na(oddsratio) & !is.infinite(oddsratio)) unksub <- subset(races, RACE == "UNK" & !is.na(oddsratio) & !is.infinite(oddsratio)) modelaian <- lm(oddsratio ~ t, data=aiansub) modelasn <- lm(oddsratio ~ t, data=asnsub) modelblk <- lm(oddsratio ~ t, data=blksub) modelmlt <- lm(oddsratio ~ t, data=mltothsub) modelunk <- lm(oddsratio ~ t, data=unksub) sexes\$oddratio = 0 for(i in 0:179) { for(j in 1:3) { a = sexes\$survived[(i*3)+2] c = sexes\$evdeath[(i*3)+2] if(j == 2) { sexes\$oddsratio[(i*3)+j] = 1.00 next } b = sexes\$survived[(i*3)+j] d = sexes\$evdeath[(i*3)+j] sexes\$oddsratio[(i*3)+j] = (a * d) / (b * c) } } femalesub <- subset(sexes, SEX == "FEMALE" & !is.na(oddsratio) & !is.infinite(oddsratio)) othersub <- subset(sexes, SEX == "OTHER" & !is.na(oddsratio) & !is.infinite(oddsratio)) femodel <- lm(oddsratio ~ t, data=femalesub) othmodel <- lm(oddsratio ~ t, data=othersub)