comparison insect_phenology_model.R @ 28:afe6d8bac0c0 draft

Uploaded
author greg
date Mon, 12 Mar 2018 09:15:16 -0400
parents 452e0e189e84
children ef6aa8c21729
comparison
equal deleted inserted replaced
27:452e0e189e84 28:afe6d8bac0c0
1055 temperature_data_frame = append_vector(temperature_data_frame, eggs.std_error, "EGGSE"); 1055 temperature_data_frame = append_vector(temperature_data_frame, eggs.std_error, "EGGSE");
1056 } 1056 }
1057 if (process_nymphs) { 1057 if (process_nymphs) {
1058 # Calculate nymph populations for selected life stage. 1058 # Calculate nymph populations for selected life stage.
1059 for (life_stage_nymph in life_stages_nymph) { 1059 for (life_stage_nymph in life_stages_nymph) {
1060 if (life_stage_nymph=="Total") { 1060 if (life_stage_nymph=="Young") {
1061 # Mean value for all nymphs.
1062 total_nymphs = apply((YoungNymphs.replications+OldNymphs.replications), 1, mean);
1063 temperature_data_frame = append_vector(temperature_data_frame, total_nymphs, "TOTALNYMPH");
1064 # Standard error for all nymphs.
1065 total_nymphs.std_error = apply((YoungNymphs.replications+OldNymphs.replications) / sqrt(opt$replications), 1, sd);
1066 temperature_data_frame = append_vector(temperature_data_frame, total_nymphs.std_error, "TOTALNYMPHSE");
1067 } else if (life_stage_nymph=="Young") {
1068 # Mean value for young nymphs. 1061 # Mean value for young nymphs.
1069 young_nymphs = apply(YoungNymphs.replications, 1, mean); 1062 young_nymphs = apply(YoungNymphs.replications, 1, mean);
1070 temperature_data_frame = append_vector(temperature_data_frame, young_nymphs, "YOUNGNYMPH"); 1063 temperature_data_frame = append_vector(temperature_data_frame, young_nymphs, "YOUNGNYMPH");
1071 # Standard error for young nymphs. 1064 # Standard error for young nymphs.
1072 young_nymphs.std_error = apply(YoungNymphs.replications / sqrt(opt$replications), 1, sd); 1065 young_nymphs.std_error = apply(YoungNymphs.replications / sqrt(opt$replications), 1, sd);
1076 old_nymphs = apply(OldNymphs.replications, 1, mean); 1069 old_nymphs = apply(OldNymphs.replications, 1, mean);
1077 temperature_data_frame = append_vector(temperature_data_frame, old_nymphs, "OLDNYMPH"); 1070 temperature_data_frame = append_vector(temperature_data_frame, old_nymphs, "OLDNYMPH");
1078 # Standard error for old nymphs. 1071 # Standard error for old nymphs.
1079 old_nymphs.std_error = apply(OldNymphs.replications / sqrt(opt$replications), 1, sd); 1072 old_nymphs.std_error = apply(OldNymphs.replications / sqrt(opt$replications), 1, sd);
1080 temperature_data_frame = append_vector(temperature_data_frame, old_nymphs.std_error, "OLDNYMPHSE"); 1073 temperature_data_frame = append_vector(temperature_data_frame, old_nymphs.std_error, "OLDNYMPHSE");
1074 } else if (life_stage_nymph=="Total") {
1075 # Mean value for all nymphs.
1076 total_nymphs = apply((YoungNymphs.replications+OldNymphs.replications), 1, mean);
1077 temperature_data_frame = append_vector(temperature_data_frame, total_nymphs, "TOTALNYMPH");
1078 # Standard error for all nymphs.
1079 total_nymphs.std_error = apply((YoungNymphs.replications+OldNymphs.replications) / sqrt(opt$replications), 1, sd);
1080 temperature_data_frame = append_vector(temperature_data_frame, total_nymphs.std_error, "TOTALNYMPHSE");
1081 } 1081 }
1082 } 1082 }
1083 } 1083 }
1084 if (process_adults) { 1084 if (process_adults) {
1085 # Calculate adult populations for selected life stage. 1085 # Calculate adult populations for selected life stage.
1086 for (life_stage_adult in life_stages_adult) { 1086 for (life_stage_adult in life_stages_adult) {
1087 if (life_stage_adult=="Total") { 1087 if (life_stage_adult == "Pre-vittelogenic") {
1088 # Mean value for all adults.
1089 total_adults = apply((Previttelogenic.replications+Vittelogenic.replications+Diapausing.replications), 1, mean);
1090 temperature_data_frame = append_vector(temperature_data_frame, total_adults, "TOTALADULT");
1091 # Standard error for all adults.
1092 total_adults.std_error = apply((Previttelogenic.replications+Vittelogenic.replications+Diapausing.replications), 1, sd) / sqrt(opt$replications);
1093 temperature_data_frame = append_vector(temperature_data_frame, total_adults.std_error, "TOTALADULTSE");
1094 } else if (life_stage_adult == "Pre-vittelogenic") {
1095 # Mean value for previttelogenic adults. 1088 # Mean value for previttelogenic adults.
1096 previttelogenic_adults = apply(Previttelogenic.replications, 1, mean); 1089 previttelogenic_adults = apply(Previttelogenic.replications, 1, mean);
1097 temperature_data_frame = append_vector(temperature_data_frame, previttelogenic_adults, "PRE-VITADULT"); 1090 temperature_data_frame = append_vector(temperature_data_frame, previttelogenic_adults, "PRE-VITADULT");
1098 # Standard error for previttelogenic adults. 1091 # Standard error for previttelogenic adults.
1099 previttelogenic_adults.std_error = apply(Previttelogenic.replications, 1, sd) / sqrt(opt$replications); 1092 previttelogenic_adults.std_error = apply(Previttelogenic.replications, 1, sd) / sqrt(opt$replications);
1110 diapausing_adults = apply(Diapausing.replications, 1, mean); 1103 diapausing_adults = apply(Diapausing.replications, 1, mean);
1111 temperature_data_frame = append_vector(temperature_data_frame, diapausing_adults, "DIAPAUSINGADULT"); 1104 temperature_data_frame = append_vector(temperature_data_frame, diapausing_adults, "DIAPAUSINGADULT");
1112 # Standard error for vittelogenic adults. 1105 # Standard error for vittelogenic adults.
1113 diapausing_adults.std_error = apply(Diapausing.replications, 1, sd) / sqrt(opt$replications); 1106 diapausing_adults.std_error = apply(Diapausing.replications, 1, sd) / sqrt(opt$replications);
1114 temperature_data_frame = append_vector(temperature_data_frame, diapausing_adults.std_error, "DIAPAUSINGADULTSE"); 1107 temperature_data_frame = append_vector(temperature_data_frame, diapausing_adults.std_error, "DIAPAUSINGADULTSE");
1108 } else if (life_stage_adult=="Total") {
1109 # Mean value for all adults.
1110 total_adults = apply((Previttelogenic.replications+Vittelogenic.replications+Diapausing.replications), 1, mean);
1111 temperature_data_frame = append_vector(temperature_data_frame, total_adults, "TOTALADULT");
1112 # Standard error for all adults.
1113 total_adults.std_error = apply((Previttelogenic.replications+Vittelogenic.replications+Diapausing.replications), 1, sd) / sqrt(opt$replications);
1114 temperature_data_frame = append_vector(temperature_data_frame, total_adults.std_error, "TOTALADULTSE");
1115 } 1115 }
1116 } 1116 }
1117 } 1117 }
1118 1118
1119 if (plot_generations_separately) { 1119 if (plot_generations_separately) {