# ==============================================================================
# GTWR MODELING: BANJIR SUMATERA (2010-2024)
# Hybrid Style: Logic GTWR + Style Modern Data Science
# ==============================================================================

# 1. Library & Data Preparation ------------------------------------------------
libs <- c("readxl", "tidyverse", "plm", "lmtest", "GWmodel", "sf", 
          "rnaturalearth", "rnaturalearthdata", "kableExtra", "viridis", 
          "jsonlite", "forecast", "tseries")
lapply(libs, require, character.only = TRUE)
## Loading required package: readxl
## Loading required package: tidyverse
## Warning: package 'tidyverse' was built under R version 4.5.2
## Warning: package 'ggplot2' was built under R version 4.5.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   4.0.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.1.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## Loading required package: plm
## Warning: package 'plm' was built under R version 4.5.2
## 
## Attaching package: 'plm'
## 
## The following objects are masked from 'package:dplyr':
## 
##     between, lag, lead
## 
## Loading required package: lmtest
## Warning: package 'lmtest' was built under R version 4.5.2
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## Loading required package: GWmodel
## Warning: package 'GWmodel' was built under R version 4.5.2
## Loading required package: robustbase
## Warning: package 'robustbase' was built under R version 4.5.2
## Loading required package: sp
## Warning: package 'sp' was built under R version 4.5.2
## Loading required package: Rcpp
## Welcome to GWmodel version 2.4-2.
## Loading required package: sf
## Warning: package 'sf' was built under R version 4.5.2
## Linking to GEOS 3.13.1, GDAL 3.11.4, PROJ 9.7.0; sf_use_s2() is TRUE
## Loading required package: rnaturalearth
## Warning: package 'rnaturalearth' was built under R version 4.5.2
## Loading required package: rnaturalearthdata
## Warning: package 'rnaturalearthdata' was built under R version 4.5.2
## 
## Attaching package: 'rnaturalearthdata'
## 
## The following object is masked from 'package:rnaturalearth':
## 
##     countries110
## 
## Loading required package: kableExtra
## Warning: package 'kableExtra' was built under R version 4.5.2
## 
## Attaching package: 'kableExtra'
## 
## The following object is masked from 'package:dplyr':
## 
##     group_rows
## 
## Loading required package: viridis
## Warning: package 'viridis' was built under R version 4.5.2
## Loading required package: viridisLite
## Loading required package: jsonlite
## 
## Attaching package: 'jsonlite'
## 
## The following object is masked from 'package:purrr':
## 
##     flatten
## 
## Loading required package: forecast
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo 
## Loading required package: tseries
## [[1]]
## [1] TRUE
## 
## [[2]]
## [1] TRUE
## 
## [[3]]
## [1] TRUE
## 
## [[4]]
## [1] TRUE
## 
## [[5]]
## [1] TRUE
## 
## [[6]]
## [1] TRUE
## 
## [[7]]
## [1] TRUE
## 
## [[8]]
## [1] TRUE
## 
## [[9]]
## [1] TRUE
## 
## [[10]]
## [1] TRUE
## 
## [[11]]
## [1] TRUE
## 
## [[12]]
## [1] TRUE
## 
## [[13]]
## [1] TRUE
# --- KONFIGURASI ---
setwd("D:/Kuliah/Lomba/PILMAPRES")
file_path <- "data_banjir_kabkotasumatera.xlsx" 
sheet_name <- "6VarUTM" # Pastikan sheet ini berisi data panel 2010-2024 (150 baris)

# --- LOAD DATA ---
banjir <- read_excel(file_path, sheet = sheet_name)

# Pastikan nama kolom sesuai standar
# Asumsi: Y=Banjir, X1=Defor, X2=HutanPrimer, X3=Sawit, X4=Hujan, X5=Penduduk, X6=Elevasi,
# Jika X6 belum ada di excel, hapus dari formula di bawah
colnames(banjir) <- c("KABKOT", "TAHUN", "Y", "X1", "X2", "X3", "X4", "X5", "X6") 

# Ubah tipe data
banjir$KABKOT <- as.factor(toupper(banjir$KABKOT))
banjir$TAHUN_NUM <- as.numeric(as.character(banjir$TAHUN)) # Untuk kalkulasi jarak waktu
banjir$TAHUN <- as.factor(banjir$TAHUN) # Untuk grouping

# --- GEOMETRI & KOORDINAT (Otomatis dari JSON Github) ---
# Mengambil koordinat centroid provinsi Indonesia
geo_file <- "gabungan_154_wilayah_batas_kabkota.geojson"
indo_map_sf <- st_read(geo_file, quiet = TRUE)


# 2. Hitung Titik Tengah (Centroid) menggunakan sf
# st_centroid akan otomatis mencari titik tengah dari geometri GeoJSON
indo_map_sf <- st_make_valid(indo_map_sf)
centroids_sf <- st_centroid(indo_map_sf)
## Warning: st_centroid assumes attributes are constant over geometries
coords_mat <- st_coordinates(centroids_sf) # Mengambil X (Long) dan Y (Lat)

# 3. Ekstrak menjadi Dataframe
# PENTING: Cek nama kolom di GeoJSON Anda! 
# Biasanya bukan 'NAME_2', tapi mungkin 'WADMKK', 'NAMEOBJ', atau 'Kabupaten'.
# Silakan ganti 'NAMA_KOLOM_KABUPATEN_DI_GEOJSON' di bawah ini dengan nama kolom yang benar di file Anda.
wilayah_coords <- data.frame(
  KABKOT = indo_map_sf$name, 
  LONG = coords_mat[,1], # Kolom 1 biasanya X/Longitude
  LAT = coords_mat[,2]   # Kolom 2 biasanya Y/Latitude
)

# 4. Ubah nama menjadi Huruf Kapital semua agar cocok dengan data BPS/BNPB Anda
wilayah_coords$KABKOT <- toupper(wilayah_coords$KABKOT)

# Join Data Banjir dengan Koordinat
df_gtwr <- banjir %>%
  # Pastikan nama kolom kunci sama (misal di data banjir namanya "KABKOT")
  left_join(wilayah_coords, by = "KABKOT") %>%
  select(KABKOT, TAHUN, LAT, LONG, everything())

# Cek Struktur Data
glimpse(df_gtwr)
## Rows: 1,078
## Columns: 12
## $ KABKOT    <chr> "KABUPATEN SIMEULUE", "KABUPATEN ACEH SINGKIL", "KABUPATEN A…
## $ TAHUN     <fct> 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, …
## $ LAT       <dbl> 2.6134016, 2.3483940, 3.1615679, 3.3689594, 4.6309514, 4.519…
## $ LONG      <dbl> 96.08571, 97.84740, 97.43667, 97.69742, 97.62602, 96.88175, …
## $ Y         <dbl> 4, 3, 14, 12, 2, 4, 6, 4, 2, 5, 8, 4, 2, 8, 2, 10, 1, 0, 0, …
## $ X1        <dbl> 330, 2963, 2699, 1285, 5447, 3643, 2450, 873, 739, 1215, 499…
## $ X2        <dbl> 3813, 32346, 10578, 2658, 26177, 0, 9493, 1664, 100, 4144, 1…
## $ X3        <dbl> 0, 1, 2, 0, 3, 7, 2, 8, 3, 3, 2, 3, 0, 1, 5, 4, 9, 2, 2, 4, …
## $ X4        <dbl> 45, 56, 61, 50, 68, 48, 70, 141, 142, 243, 189, 99, 16, 149,…
## $ X5        <dbl> 7.9902825, 3.2975609, 14.4377547, 19.5533505, 9.1178308, 17.…
## $ X6        <dbl> 76.23707, 55.36169, 573.82609, 1146.55040, 349.74889, 1275.7…
## $ TAHUN_NUM <dbl> 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, …
# 2. Panel Data Diagnostic (Justifikasi Model) ---------------------------------
# Langkah ini penting untuk laporan: Membuktikan OLS biasa tidak cukup.

# Formula Model (Sesuaikan X6 jika sudah masuk Excel)
form_eq <- Y ~ X1 + X2 + X3 + X4 + X5 + X6

# Estimasi Model Dasar
cem <- plm(form_eq, data = df_gtwr, model = "pooling")
fem <- plm(form_eq, data = df_gtwr, index = c("KABKOT", "TAHUN"), model = "within")
rem <- plm(form_eq, data = df_gtwr, index = c("KABKOT", "TAHUN"), model = "random")

# Uji Pemilihan Model
chow <- pooltest(cem, fem)
hausman <- phtest(fem, rem)
bp_lm <- plmtest(cem, type="bp", effect="twoways")

# Tabel Hasil Uji Diagnostik
hasil_uji <- data.frame(
  Uji = c("Chow Test (Pool vs Fixed)", "Hausman Test (Fixed vs Random)", "BP LM Test (Pool vs Random)"),
  Statistik = round(c(chow$statistic, hausman$statistic, bp_lm$statistic), 2),
  P_Value = c(chow$p.value, hausman$p.value, bp_lm$p.value)
) %>% mutate(
  Kesimpulan = case_when(
    P_Value < 0.05 & Uji == "Chow Test (Pool vs Fixed)" ~ "Tolak H0 (Pilih Fixed Effects)",
    P_Value < 0.05 & Uji == "Hausman Test (Fixed vs Random)" ~ "Tolak H0 (Pilih Fixed Effects)",
    P_Value < 0.05 & Uji == "BP LM Test (Pool vs Random)" ~ "Tolak H0 (Ada Efek Panel)",
    TRUE ~ "Terima H0"
  ),
  P_Value_Str = format.pval(P_Value, digits=3, eps=0.001)
)

kable(hasil_uji[,c("Uji", "Statistik", "P_Value_Str", "Kesimpulan")], 
      caption = "Diagnostik Data Panel (Bukti Heterogenitas Spasial & Temporal)") %>%
  kable_styling(bootstrap_options = "striped", full_width = F)
Diagnostik Data Panel (Bukti Heterogenitas Spasial & Temporal)
Uji Statistik P_Value_Str Kesimpulan
Chow Test (Pool vs Fixed) 4.03 <0.001 Tolak H0 (Pilih Fixed Effects)
Hausman Test (Fixed vs Random) 2.76 0.599 Terima H0
BP LM Test (Pool vs Random) 341.09 <0.001 Tolak H0 (Ada Efek Panel)
# 3. GTWR Estimation (Inti Model) ----------------------------------------------

# Konversi ke Spatial Object
df_sp <- df_gtwr
coordinates(df_sp) <- ~LONG+LAT
proj4string(df_sp) <- CRS("+proj=longlat +datum=WGS84")

# A. Bandwidth Selection (Cross Validation)
# adaptive = TRUE (menggunakan jumlah tetangga/neighbor terdekat, misal: 10 provinsi terdekat)
# adaptive = FALSE (menggunakan jarak fix dalam km/derajat)
print("Sedang mencari Bandwidth Optimal (bisa memakan waktu)...")
## [1] "Sedang mencari Bandwidth Optimal (bisa memakan waktu)..."
bw_gtwr <- bw.gtwr(form_eq, 
                   data = df_sp, 
                   obs.tv = df_sp$TAHUN_NUM, # Variabel Waktu
                   approach = "CV", 
                   kernel = "tricube", 
                   adaptive = TRUE) # Menggunakan Adaptive agar robust terhadap kepadatan wilayah
## Adaptive bandwidth: 673 CV score: 7620.298 
## Adaptive bandwidth: 424 CV score: 7521.564 
## Adaptive bandwidth: 268 CV score: 7497.887 
## Adaptive bandwidth: 174 CV score: 7718.833 
## Adaptive bandwidth: 328 CV score: 7496.579 
## Adaptive bandwidth: 363 CV score: 7499.83 
## Adaptive bandwidth: 304 CV score: 7487.009 
## Adaptive bandwidth: 291 CV score: 7492.066 
## Adaptive bandwidth: 314 CV score: 7498.087 
## Adaptive bandwidth: 300 CV score: 7487.46 
## Adaptive bandwidth: 309 CV score: 7501.54 
## Adaptive bandwidth: 303 CV score: 7487.641 
## Adaptive bandwidth: 306 CV score: 7486.11 
## Adaptive bandwidth: 306 CV score: 7486.11
print(paste("Bandwidth Optimal (Jumlah Tetangga):", bw_gtwr))
## [1] "Bandwidth Optimal (Jumlah Tetangga): 306"
# B. Fitting Model GTWR
model_gtwr <- gtwr(form_eq, 
                   data = df_sp, 
                   obs.tv = df_sp$TAHUN_NUM, 
                   st.bw = bw_gtwr, 
                   kernel = "tricube", 
                   adaptive = TRUE)
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Warning in sigma.hat1 * betas.SE[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
# C. Tampilkan Ringkasan
print(model_gtwr$GTW.diagnostic)
## $RSS.gw
##          [,1]
## [1,] 6760.556
## 
## $AIC
##          [,1]
## [1,] 5076.701
## 
## $AICc
##          [,1]
## [1,] 5120.011
## 
## $enp
## [1] 41.72897
## 
## $edf
## [1] 1036.271
## 
## $gw.R2
##           [,1]
## [1,] 0.2592845
## 
## $gwR2.adj
##           [,1]
## [1,] 0.2294283
print(summary(model_gtwr$SDF))
## Object of class SpatialPointsDataFrame
## Coordinates:
##            min        max
## LONG 95.305768 108.262294
## LAT  -5.529899   5.837553
## Is projected: FALSE 
## proj4string : [+proj=longlat +datum=WGS84 +no_defs]
## Number of points: 1078
## Data attributes:
##    Intercept             X1                   X2                  X3        
##  Min.   :-0.3359   Min.   :-4.857e-05   Min.   :7.672e-07   Min.   :0.1673  
##  1st Qu.:-0.1626   1st Qu.:-4.840e-06   1st Qu.:2.128e-06   1st Qu.:0.1970  
##  Median : 0.2371   Median : 7.664e-05   Median :7.500e-06   Median :0.2261  
##  Mean   : 0.3387   Mean   : 6.308e-05   Mean   :9.246e-06   Mean   :0.3006  
##  3rd Qu.: 0.8381   3rd Qu.: 1.040e-04   3rd Qu.:1.301e-05   3rd Qu.:0.4280  
##  Max.   : 1.1767   Max.   : 1.596e-04   Max.   :2.826e-05   Max.   :0.7051  
##        X4                  X5                X6                   y         
##  Min.   :3.787e-05   Min.   :0.08684   Min.   :-0.0016396   Min.   : 0.000  
##  1st Qu.:1.539e-04   1st Qu.:0.14864   1st Qu.:-0.0013881   1st Qu.: 0.000  
##  Median :1.870e-04   Median :0.17874   Median :-0.0010925   Median : 1.000  
##  Mean   :2.093e-04   Mean   :0.19560   Mean   :-0.0009231   Mean   : 2.327  
##  3rd Qu.:2.989e-04   3rd Qu.:0.26375   3rd Qu.:-0.0007219   3rd Qu.: 3.000  
##  Max.   :3.625e-04   Max.   :0.30565   Max.   : 0.0010923   Max.   :19.000  
##       yhat            residual          time_stamp   Stud_residual     
##  Min.   :-0.6371   Min.   :-6.10362   Min.   :2018   Min.   :-2.48567  
##  1st Qu.: 1.3991   1st Qu.:-1.57043   1st Qu.:2019   1st Qu.:-0.62246  
##  Median : 2.0761   Median :-0.57014   Median :2021   Median :-0.22697  
##  Mean   : 2.2745   Mean   : 0.05208   Mean   :2021   Mean   : 0.01964  
##  3rd Qu.: 2.8729   3rd Qu.: 1.06876   3rd Qu.:2023   3rd Qu.: 0.43032  
##  Max.   :12.2007   Max.   :13.10827   Max.   :2024   Max.   : 5.45871  
##   Intercept_SE        X1_SE               X2_SE               X3_SE        
##  Min.   :0.4186   Min.   :3.910e-05   Min.   :3.392e-06   Min.   :0.03428  
##  1st Qu.:0.4332   1st Qu.:5.081e-05   1st Qu.:3.991e-06   1st Qu.:0.04419  
##  Median :0.4460   Median :5.693e-05   Median :4.345e-06   Median :0.06784  
##  Mean   :0.4533   Mean   :5.694e-05   Mean   :4.415e-06   Mean   :0.06777  
##  3rd Qu.:0.4582   3rd Qu.:6.557e-05   3rd Qu.:4.572e-06   3rd Qu.:0.08566  
##  Max.   :0.5155   Max.   :7.461e-05   Max.   :5.694e-06   Max.   :0.11284  
##      X4_SE               X5_SE             X6_SE            Intercept_TV    
##  Min.   :0.0001241   Min.   :0.05940   Min.   :0.0007474   Min.   :-0.7529  
##  1st Qu.:0.0001436   1st Qu.:0.06418   1st Qu.:0.0007849   1st Qu.:-0.3701  
##  Median :0.0001537   Median :0.06746   Median :0.0008380   Median : 0.5439  
##  Mean   :0.0001568   Mean   :0.06792   Mean   :0.0008411   Mean   : 0.7711  
##  3rd Qu.:0.0001629   3rd Qu.:0.06961   3rd Qu.:0.0008718   3rd Qu.: 1.8816  
##  Max.   :0.0001958   Max.   :0.07822   Max.   :0.0009577   Max.   : 2.6507  
##      X1_TV              X2_TV            X3_TV           X4_TV       
##  Min.   :-0.74073   Min.   :0.1922   Min.   :1.806   Min.   :0.2330  
##  1st Qu.:-0.08612   1st Qu.:0.4143   1st Qu.:2.649   1st Qu.:0.8253  
##  Median : 1.27626   Median :1.6476   Median :4.561   Median :1.2512  
##  Mean   : 1.08931   Mean   :2.2975   Mean   :4.600   Mean   :1.3774  
##  3rd Qu.: 1.96102   3rd Qu.:3.4126   3rd Qu.:5.718   3rd Qu.:2.0555  
##  Max.   : 2.53816   Max.   :7.1240   Max.   :8.967   Max.   :2.6863  
##      X5_TV           X6_TV        
##  Min.   :1.269   Min.   :-2.0152  
##  1st Qu.:2.208   1st Qu.:-1.7121  
##  Median :2.735   Median :-1.3123  
##  Mean   :2.868   Mean   :-1.0911  
##  3rd Qu.:3.636   3rd Qu.:-0.8647  
##  Max.   :4.639   Max.   : 1.2442
# 4. Result Extraction & Table -------------------------------------------------

# Ambil hasil koefisien
results_sdf <- as.data.frame(model_gtwr$SDF) %>%
  mutate(KABKOT = df_gtwr$KABKOT, TAHUN = df_gtwr$TAHUN) %>%
  dplyr::select(KABKOT, TAHUN, y, yhat, contains("X")) # Ambil kolom X (koefisien)

# Hitung R2 Lokal (Pseudo R2 per lokasi)
results_sdf$residual <- results_sdf$y - results_sdf$yhat
RSS_lokal <- results_sdf$residual^2
TSS_lokal <- (results_sdf$y - mean(results_sdf$y))^2
results_sdf$Local_R2 <- 1 - (RSS_lokal/TSS_lokal)

# Tabel Parameter Global vs Rata-rata Lokal
summary_global <- summary(cem)$coefficients
summary_gtwr <- results_sdf %>% 
  summarise(across(starts_with("X"), mean)) %>%
  pivot_longer(everything(), names_to = "Variabel", values_to = "Mean_Coef_GTWR")

kable(summary_gtwr, caption = "Rata-rata Koefisien GTWR Seluruh Sumatera (2010-2024)")
Rata-rata Koefisien GTWR Seluruh Sumatera (2010-2024)
Variabel Mean_Coef_GTWR
X1 0.0000631
X2 0.0000092
X3 0.3005692
X4 0.0002093
X5 0.1955956
X6 -0.0009231
X1_SE 0.0000569
X2_SE 0.0000044
X3_SE 0.0677670
X4_SE 0.0001568
X5_SE 0.0679152
X6_SE 0.0008411
X1_TV 1.0893121
X2_TV 2.2974632
X3_TV 4.5995219
X4_TV 1.3774218
X5_TV 2.8684931
X6_TV -1.0910876
# 5. Visualization (Peta Koefisien) --------------------------------------------

# Siapkan Peta Dasar (Shapefile)
library(ggplot2)
library(dplyr)
library(viridis)
library(patchwork) # Untuk menggabungkan banyak peta jika diperlukan
## Warning: package 'patchwork' was built under R version 4.5.2
# # 1. Penyiapan Peta (Gunakan kolom 'name' sesuai dataset Anda)
map_sumatera <- indo_map_sf %>%
  mutate(KABKOT_JOIN = toupper(trimws(name))) # Standardisasi: Kapital & Tanpa Spasi

# 2. Fungsi Plotting yang Diperbaiki
plot_gtwr_map <- function(data_res, tahun_target, variabel, nama_asli_var) {

  # Penyiapan data hasil GTWR
  data_filter <- data_res %>%
    filter(TAHUN == tahun_target) %>%
    mutate(KABKOT_JOIN = toupper(trimws(KABKOT))) # Samakan dengan peta

  # Join dengan Shapefile
  map_data <- map_sumatera %>%
    left_join(data_filter, by = "KABKOT_JOIN")

  # Plotting
  ggplot(map_data) +
    geom_sf(aes(fill = .data[[variabel]]), color = "black", size = 0.1) +
    # Menampilkan label nama provinsi agar peta informatif
    scale_fill_viridis(option = "plasma", name = "Koefisien", na.value = "grey90") +
    labs(
      title = paste("Koefisien", nama_asli_var),
      subtitle = paste("Tahun:", tahun_target),
      caption = "GTWR Adaptive Kernel"
    ) +
    theme_void() + # Lebih bersih untuk peta
    theme(
      legend.position = "right",
      plot.title = element_text(size = 10, face = "bold"),
      plot.subtitle = element_text(size = 8)
    )
}

# 3. List Variabel dan Nama Aslinya (Sesuaikan dengan data Anda)
var_list <- list(
  X1 = "Hutan Primer",
  X2 = "Sawit",
  X3 = "Cuaca Ekstem",
  X4 = "Penduduk",
  X5 = "Elevasi",
  X6 = "Kemiringan"
)
# 
# # 4. Generate p1 sampai p6 secara otomatis
# plots <- list()
# for (i in 1:6) {
#   var_code <- paste0("X", i)
#   plots[[var_code]] <- plot_gtwr_map(
#     results_sdf,
#     2024,
#     var_code,
#     var_list[[var_code]]
#   )
# }
# 
# # 5. Cara memanggil/menampilkan
# # Anda bisa memanggil satu per satu:
# # 2. Menggabungkan p1 sampai p6
# # Kita gunakan objek dari list 'plots' yang sudah Anda buat sebelumnya
# combined_map <- (plots$X1 + plots$X2 + plots$X3) /
#   (plots$X4 + plots$X5 + plots$X6)
# 
# # 3. Menambahkan Judul Besar, Gaya Visual, dan Tema Kolektif
# final_plot <- combined_map +
#   plot_annotation(
#     title = 'Analisis Spasial Koefisien Variabel Terhadap Banjir di Sumatera',
#     subtitle = 'Hasil Model GTWR Tahun 2024 (Adaptive Kernel)',
#     caption = 'Data: Hasil Olahan GTWR | Sumbu warna menunjukkan kekuatan pengaruh variabel terhadap kejadian banjir',
#     theme = theme(
#       plot.title = element_text(size = 18, face = "bold", hjust = 0.5),
#       plot.subtitle = element_text(size = 14, hjust = 0.5, color = "grey30"),
#       plot.caption = element_text(size = 10)
#     )
#   ) +
#   plot_layout(guides = "collect") # Ini akan menyatukan legend agar tidak berantakan
# 
# # 4. Tampilkan di RStudio
# print(final_plot)

# ==============================================================================
# PERBAIKAN JOIN KABUPATEN/KOTA (FIX ERROR KABKOT_JOIN)
# ==============================================================================

# 1. Pastikan Shapefile Punya Kolom Kunci yang Benar
# Kita bersihkan dulu map_sumatera agar tidak ada kolom duplikat
map_sumatera_clean <- map_sumatera %>%
  mutate(KABKOT_JOIN = toupper(trimws(as.character(name)))) # Pastikan 'name' adalah kolom nama KabKot

# 2. Fungsi Plotting yang Lebih Robust
plot_gtwr_kabkot_fix <- function(data_res, tahun_target, variabel, nama_asli_var) {
  
  # A. Filter dan Siapkan Data Atribut
  data_filter <- data_res %>% 
    as.data.frame() %>% # Ubah ke DF biasa dulu agar join lebih stabil
    filter(TAHUN == tahun_target) %>%
    # PASTIKAN kolom KABKOT ada di results_sdf. Jika namanya lain (misal: 'KAB_KOTA'), ganti di sini:
    mutate(KABKOT_JOIN = toupper(trimws(as.character(KABKOT)))) 
  
  # B. Join dengan Shapefile
  # Kita gunakan 'by = "KABKOT_JOIN"' secara eksplisit
  map_data <- map_sumatera_clean %>% 
    left_join(data_filter, by = "KABKOT_JOIN")
  
  # C. Cek apakah join berhasil (Optional untuk debug)
  # print(paste("Jumlah baris setelah join:", nrow(map_data)))
  
  # D. Plotting
  ggplot(map_data) +
    geom_sf(aes(fill = .data[[variabel]]), color = "black", size = 0.05) +
    scale_fill_viridis(
      option = "plasma", 
      name = NULL,
      na.value = "grey90", # Warna jika ada kabkot yang tidak ter-join
      guide = guide_colorbar(
        barwidth = unit(0.25, "cm"), 
        barheight = unit(2.5, "cm")
      )
    ) +
    labs(title = nama_asli_var) +
    theme_void() +
    theme(
      legend.position = "right",
      legend.text = element_text(size = 6),
      plot.title = element_text(size = 9, face = "bold", hjust = 0.5),
      plot.margin = margin(2, 2, 2, 2)
    )
}

# 3. Jalankan Ulang Loop
plots <- list()
for (i in 1:6) {
  var_code <- paste0("X", i)
  plots[[var_code]] <- plot_gtwr_kabkot_fix(results_sdf, 2024, var_code, var_list[[var_code]])
}

# 4. Gabungkan
combined_kabkot_fix <- wrap_plots(plots, ncol = 3)
print(combined_kabkot_fix)

# Atau menampilkan semua dalam satu layout (menggunakan library patchwork)
# (plots$X1 + plots$X2 + plots$X3) / (plots$X4 + plots$X5 + plots$X6)

# 6. Forecasting (Model M1: Freeze Beta 2024) ----------------------------------
# Logika: Menggunakan Koefisien (Beta) tahun 2024 untuk memprediksi masa depan
# dengan asumsi hubungan antar variabel tetap, tapi nilai X berubah.

future_years <- 2025:2030
vars_pred <- c("X1", "X2", "X3", "X4", "X5", "X6")

# A. Ambil Beta Terakhir (2024)
beta_2024 <- results_sdf %>% 
  filter(TAHUN == 2024) %>%
  dplyr::select(KABKOT, yhat, all_of(vars_pred))

# B. Forecast Nilai X (ARIMA Sederhana untuk X1..X6)
# Fungsi forecast per provinsi per variabel
forecast_x <- function(data_hist, KABKOT, n_ahead) {
  res_list <- list()
  for (v in vars_pred) {
    ts_data <- ts(data_hist %>% filter(KABKOT == KABKOT) %>% pull(v), start = 2018)
    # Gunakan auto.arima atau naive method jika data terlalu pendek
    fit <- auto.arima(ts_data) 
    fc <- forecast(fit, h = n_ahead)$mean
    res_list[[v]] <- as.numeric(fc)
  }
  return(as.data.frame(res_list))
}

# Loop Forecasting
future_data_list <- list()
for (p in unique(df_gtwr$KABKOT)) {
  fc_val <- forecast_x(df_gtwr, p, length(future_years))
  fc_val$KABKOT <- p
  fc_val$TAHUN <- future_years
  future_data_list[[p]] <- fc_val
}
df_future_X <- bind_rows(future_data_list)

# C. Hitung Y Prediksi (Y = Beta2024 * X_Future)
df_forecast <- df_future_X %>%
  left_join(beta_2024, by = "KABKOT") %>%
  mutate(
    Y_Pred = yhat + 
      (X1.x * X1.y) + (X2.x * X2.y) + (X3.x * X3.y) + 
      (X4.x * X4.y) + (X5.x * X5.y) + (X6.x * X6.y)
    # .x adalah nilai X masa depan, .y adalah koefisien beta 2024
  ) %>%
  dplyr::select(KABKOT, TAHUN, Y_Pred)

# Tampilkan Hasil Forecast 2030
print(head(df_forecast %>% filter(TAHUN == 2030) %>% arrange(desc(Y_Pred))))
##                       KABKOT TAHUN    Y_Pred
## 1     KABUPATEN DELI SERDANG  2030 15.119400
## 2           KABUPATEN KAMPAR  2030 13.192363
## 3       KABUPATEN ROKAN HULU  2030  9.825619
## 4       KABUPATEN SIMALUNGUN  2030  8.612440
## 5 KABUPATEN KUANTAN SINGINGI  2030  8.495154
## 6        KABUPATEN BENGKALIS  2030  8.381936
# Visualisasi Forecast 2030
map_forecast <- map_sumatera %>% 
  left_join(df_forecast %>% filter(TAHUN == 2030), by = c("name" = "KABKOT"))

# ggplot(map_forecast) +
#   geom_sf(aes(fill = Y_Pred), color = "black") +
#   scale_fill_gradient(low = "yellow", high = "red", name = "Kejadian Banjir") +
#   labs(title = "Peta Prakiraan Banjir Tahun 2030", subtitle = "Skenario: Hubungan Spasial 2024 Tetap (GTWR Forecast)") +
#   theme_void()

# ==============================================================================
# 6. FORECASTING: HYBRID RANDOM FOREST (NON-LINEAR)
# ==============================================================================
library(randomForest)
## Warning: package 'randomForest' was built under R version 4.5.2
## randomForest 4.7-1.2
## Type rfNews() to see new features/changes/bug fixes.
## 
## Attaching package: 'randomForest'
## 
## The following object is masked from 'package:dplyr':
## 
##     combine
## 
## The following object is masked from 'package:ggplot2':
## 
##     margin
library(forecast)

# --- A. Persiapan Data Training & Variabel ---
# Pisahkan variabel dinamis (berubah tiap tahun) dan statis (tetap)
vars_dynamic <- c("X1", "X2", "X3", "X4") # Deforestasi, Hujan, Penduduk, dll
vars_static  <- c("X5","X6")                   # Elevasi & Slope (Tidak diprediksi ARIMA)
vars_all     <- c(vars_dynamic, vars_static)

# Training Model Random Forest pada Data Historis (2010-2024)
# Tujuannya: Agar mesin "mengerti" pola hubungan X terhadap Y
set.seed(2026) # Agar hasil konsisten
rf_model <- randomForest(
  formula = as.formula(paste("Y ~", paste(vars_all, collapse = "+"))),
  data    = df_gtwr,
  ntree   = 500,       # Jumlah pohon keputusan
  mtry    = 2,         # Jumlah variabel per percabangan
  importance = TRUE    # Hitung tingkat kepentingan variabel
)

print("Model Random Forest Berhasil Dilatih!")
## [1] "Model Random Forest Berhasil Dilatih!"
print(importance(rf_model)) # Cek variabel mana yang paling berpengaruh
##     %IncMSE IncNodePurity
## X1 20.32378      1399.444
## X2 32.34722      1708.682
## X3 31.84055      1182.063
## X4 24.21386      1495.855
## X5 34.93748      1289.675
## X6 32.96367      1068.060
imp_data <- as.data.frame(importance(rf_model))
imp_data$Variable <- rownames(imp_data)

# 2. Grafik khusus untuk %IncMSE (Ini yang paling jujur/akurat untuk karya ilmiah)
ggplot(imp_data, aes(x = reorder(Variable, `%IncMSE`), y = `%IncMSE`)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  coord_flip() + # Memutar grafik agar teks terbaca
  labs(
    title = "Faktor Kontributor Utama Banjir di Sumatera",
    subtitle = "Berdasarkan Kenaikan MSE (Mean Squared Error)",
    x = "Variabel Penelitian",
    y = "Kepentingan Variabel (% Kenaikan MSE)"
  ) +
  theme_minimal()

# --- B. Forecasting Variabel X (Masa Depan) ---
future_years <- 2025:2030

# Fungsi Forecast ARIMA (Hanya untuk variabel dinamis)
forecast_dynamic_x <- function(data_hist, KABKOT, n_ahead) {
  res_list <- list()
  for (v in vars_dynamic) {
    # Ambil data historis
    ts_val <- as.numeric(data_hist %>% filter(KABKOT == KABKOT) %>% pull(v))
    ts_data <- ts(ts_val, start = 2018)
    
    # Auto ARIMA dengan penanganan error
    fit <- tryCatch(
      auto.arima(ts_data), 
      error = function(e) auto.arima(ts_data, approximation = TRUE)
    )
    
    # Forecast & pastikan tidak ada nilai negatif (jika data fisik spt hujan/hutan)
    fc <- as.numeric(forecast(fit, h = n_ahead)$mean)
    res_list[[v]] <- ifelse(fc < 0, 0, fc) 
  }
  return(as.data.frame(res_list))
}

# Loop Forecasting X per KABKOTinsi
future_data_list <- list()
for (p in unique(df_gtwr$KABKOT)) {
  # 1. Prediksi X Dinamis (2025-2030)
  fc_val <- forecast_dynamic_x(df_gtwr, p, length(future_years))
  fc_val$KABKOT <- p
  fc_val$TAHUN <- future_years
  
  # 2. Ambil Nilai X Statis (X6, X7) dari data terakhir (2024)
  # Karena Elevasi & Slope tidak berubah, kita copy saja dari data lama
  static_val <- df_gtwr %>% 
    filter(KABKOT == p, TAHUN == 2024) %>% 
    dplyr::select(all_of(vars_static))
  
  # Gabungkan
  fc_val <- cbind(fc_val, static_val)
  
  future_data_list[[p]] <- fc_val
}

df_future_X_RF <- bind_rows(future_data_list)

# --- C. Prediksi Y (Kejadian Banjir) Menggunakan Random Forest ---
# Kita masukkan data X masa depan ke "Otak" Random Forest yang sudah dilatih

df_forecast_rf <- df_future_X_RF %>%
  mutate(
    # Prediksi menggunakan model RF
    Y_Pred = predict(rf_model, newdata = df_future_X_RF)
    
  ) %>%
  dplyr::select(KABKOT, TAHUN, Y_Pred, everything())

# Tampilkan Hasil Forecast 2030 (Top 5 Rawan)
print("Top 5 KABKOTinsi Rawan Banjir Tahun 2030 (Prediksi Random Forest):")
## [1] "Top 5 KABKOTinsi Rawan Banjir Tahun 2030 (Prediksi Random Forest):"
print(head(df_forecast_rf %>% filter(TAHUN == 2030) %>% arrange(desc(Y_Pred)), 5))
##                   KABKOT TAHUN   Y_Pred       X1      X2       X3     X4
## 1 KABUPATEN ACEH SELATAN  2030 5.801116 2501.212 23736.2 1.517194 640.55
## 2   KABUPATEN ACEH TIMUR  2030 5.687007 2501.212 23736.2 1.517194 640.55
## 3 KABUPATEN ACEH TAMIANG  2030 5.683707 2501.212 23736.2 1.517194 640.55
## 4      KABUPATEN LANGKAT  2030 5.616924 2501.212 23736.2 1.517194 640.55
## 5       KABUPATEN SELUMA  2030 5.584490 2501.212 23736.2 1.517194 640.55
##          X5       X6
## 1 14.437755 573.8261
## 2  9.117831 349.7489
## 3  7.490105 180.1956
## 4  8.528598 333.7659
## 5  8.392329 343.9923
View(df_forecast_rf)
# --- D. Visualisasi Peta Forecast 2030 ---
map_forecast_rf <- map_sumatera %>% 
  left_join(df_forecast_rf %>% filter(TAHUN == 2030), by = c("name" = "KABKOT"))

# p_rf <- ggplot(map_forecast_rf) +
#   geom_sf(aes(fill = Y_Pred), color = "black", size = 0.2) +
#   geom_sf_text(aes(label = name), size = 2, fontface = "bold", check_overlap = TRUE, color = "white") +
#   scale_fill_viridis(option = "turbo", name = "Prediksi\nKejadian") +
#   labs(
#     title = "Peta Prakiraan Banjir Sumatera Tahun 2030", 
#     subtitle = "Metode: Hybrid ARIMA-Random Forest (Non-Linear Approach)",
#     caption = "Variabel Input: Deforestasi, Hutan Primer, Sawit, Hujan, Penduduk, Elevasi, Slope"
#   ) +
#   theme_void() +
#   theme(legend.position = "right")
# 
# print(p_rf)

# ==============================================================================
# PERBAIKAN VISUALISASI FORECAST 2030 (LEVEL KABUPATEN/KOTA)
# ==============================================================================

# 1. Standardisasi Data Forecast agar siap Join
df_forecast_2030 <- df_forecast_rf %>%
  filter(TAHUN == 2030) %>%
  mutate(KABKOT_JOIN = toupper(trimws(as.character(KABKOT))))

# 2. Join dengan Shapefile (Pastikan map_sumatera sudah punya KABKOT_JOIN)
map_forecast_plot <- map_sumatera %>%
  mutate(KABKOT_JOIN = toupper(trimws(as.character(name)))) %>%
  left_join(df_forecast_2030, by = "KABKOT_JOIN")

# 3. Plotting dengan Estetika Profesional
p_rf_final <- ggplot(map_forecast_plot) +
  # Menggunakan batas wilayah yang sangat tipis agar warna prediksi terlihat jelas
  geom_sf(aes(fill = Y_Pred), color = "black", size = 0.05) +
  # Menghapus geom_sf_text agar tidak berantakan, atau gunakan hanya untuk Top 5 rawan
  scale_fill_viridis(
    option = "plasma", 
    name = "Prediksi\nKejadian",
    na.value = "grey90",
    guide = guide_colorbar(
      barwidth = unit(0.4, "cm"),
      barheight = unit(5, "cm")
    )
  ) +
  labs(
    title = "Prakiraan Risiko Banjir Pulau Sumatera Tahun 2030", 
    subtitle = "Model: Hybrid ARIMA - Random Forest (Non-Linear Analysis)",
    caption = "Variabel: Hutan Primer, Sawit, Cuaca Ekstrem, Penduduk, Elevasi, Kemiringan\nUnit Analisis: Kabupaten/Kota",
    x = NULL, y = NULL
  ) +
  theme_void() +
  theme(
    plot.title = element_text(size = 16, face = "bold", hjust = 0.5),
    plot.subtitle = element_text(size = 11, hjust = 0.5, color = "grey30"),
    legend.position = "right",
    plot.margin = ggplot2::margin(10, 10, 10, 10)
  )

# Tampilkan Peta
print(p_rf_final)

# ==============================================================================
# 7. GRAFIK TREN RATA-RATA KESELURUHAN SUMATERA (2010-2030)
# ==============================================================================
library(ggplot2)
library(dplyr)

# 1. Agregasi Data Historis (Rata-rata per Tahun)
df_hist_avg <- df_gtwr %>%
  group_by(TAHUN) %>%
  summarise(Kejadian = mean(Y, na.rm = TRUE)) %>%
  mutate(
    TAHUN = as.numeric(as.character(TAHUN)),
    Tipe = "Historis"
  )

# 2. Agregasi Data Prediksi (Rata-rata per Tahun)
df_pred_avg <- df_forecast_rf %>%
  group_by(TAHUN) %>%
  summarise(Kejadian = mean(Y_Pred, na.rm = TRUE)) %>%
  mutate(
    TAHUN = as.numeric(as.character(TAHUN)),
    Tipe = "Prediksi"
  )

# 3. Gabungkan Keduanya
# Sambungkan titik tahun 2024 agar garis tidak terputus
titik_sambung <- df_hist_avg %>% filter(TAHUN == 2024) %>% mutate(Tipe = "Prediksi")
df_gabung_avg <- bind_rows(df_hist_avg, titik_sambung, df_pred_avg) %>%
  arrange(TAHUN)

# 4. Plotting Tren Rata-rata
ggplot(df_gabung_avg, aes(x = TAHUN, y = Kejadian, group = Tipe)) +
  # Garis Tren (Solid untuk historis, Dashed untuk prediksi)
  geom_line(aes(linetype = Tipe, color = Tipe), linewidth = 1.2) +
  # Titik Data
  geom_point(aes(color = Tipe), size = 3) +
  # Garis vertikal pembatas 2024
  geom_vline(xintercept = 2024, linetype = "dotted", color = "darkgrey", linewidth = 1) +
  # Warna dan Linetype manual
  scale_color_manual(values = c("Historis" = "black", "Prediksi" = "#E64B35FF")) + # Merah untuk prediksi
  scale_linetype_manual(values = c("Historis" = "solid", "Prediksi" = "dashed")) +
  # Labeling Dinamis (Posisi teks menyesuaikan data)
  annotate("label", x = 2017, y = max(df_gabung_avg$Kejadian), label = "Data Historis", fill = "white") +
  annotate("label", x = 2027, y = max(df_gabung_avg$Kejadian), label = "Prediksi RF", fill = "#E64B35FF", color = "white") +
  # Formatting
  scale_x_continuous(breaks = seq(2010, 2030, 2)) +
  labs(
    title = "Tren Rata-rata Kejadian Banjir di Sumatera (2010 - 2030)",
    subtitle = "Agregasi Seluruh Kabupaten/Kota (Random Forest Prediction)",
    x = "Tahun",
    y = "Rata-rata Jumlah Kejadian Banjir",
    caption = "Sumber: Hasil Pemodelan Hybrid ARIMA-Random Forest"
  ) +
  theme_minimal(base_size = 14) +
  theme(
    legend.position = "bottom",
    panel.grid.minor = element_blank(),
    plot.title = element_text(face = "bold")
  )

#===============================================================================

# --- A. SKENARIO 1: Business as Usual (BAU) ---
# Logika: Mengikuti tren peramalan alami tanpa ada intervensi kebijakan tambahan.
scen_bau <- df_future_X_RF %>%
  mutate(
    Skenario = "1. Business as Usual (BAU)",
    Y_Pred = predict(rf_model, newdata = df_future_X_RF)
  )

# --- B. SKENARIO 2: Kebijakan Moderat (Fokus Pengurangan Deforestasi) ---
# Logika: Menurunkan tingkat Kehilangan Hutan Primer (X1) sebesar 20% dari tren saat ini.
# (X1 dikali 0.8 artinya deforestasi ditekan agar lebih rendah 20%)
scen_moderat <- df_future_X_RF %>%
  mutate(
    X1 = X1 * 0.5,  
    Skenario = "2. Kebijakan Moderat (Reduksi X1)"
  ) %>%
  mutate(Y_Pred = predict(rf_model, newdata = .))

# --- C. SKENARIO 3: Kebijakan Agresif (Stop Deforestasi & Kontrol Sawit) ---
# Logika: Menekan Kehilangan Hutan Primer (X1) secara drastis sebesar 50%.
# X2 (Sawit) dibiarkan sesuai tren (dikali 1) untuk melihat dampak khusus sektor kehutanan.
scen_agresif <- df_future_X_RF %>%
  mutate(
    X2 = X2 * 0.5,  
    Skenario = "3. Kebijakan Agresif (Reduksi X1 50%)"
  ) %>%
  mutate(Y_Pred = predict(rf_model, newdata = .))

# --- D. SKENARIO 4: Kebijakan TOTAL (Kehutanan, Perkebunan, & Demografi) ---
# Logika: Skenario paling ideal. Kehilangan Hutan (X1) dipotong 50%, 
# Ekspansi Sawit (X2) ditekan 50%
scen_total <- df_future_X_RF %>%
  mutate(
    X1 = X1 * 0.5,
    X2 = X2 * 0.5,  
    Skenario = "4. Kebijakan TOTAL (X1, X2)"
  ) %>%
  mutate(Y_Pred = predict(rf_model, newdata = .))

# Gabungkan Semua Skenario
df_scen_all_4 <- bind_rows(scen_bau, scen_moderat, scen_agresif, scen_total)


# 1. Pastikan Anchor 2024 menggunakan TAHUN sebagai angka murni
data_anchor_2024 <- df_gtwr %>%
  filter(TAHUN == 2024) %>%
  # Konversi TAHUN dari factor ke character lalu ke numeric (cara paling aman)
  mutate(TAHUN = as.numeric(as.character(TAHUN))) %>% 
  group_by(TAHUN) %>%
  summarise(Y_Pred = mean(Y, na.rm = TRUE))

# 2. Perbaiki Fungsi agar konsisten melakukan konversi
get_avg_scen <- function(data_scen, name) {
  data_scen %>%
    # Konversi TAHUN menjadi numeric sebelum proses apapun
    mutate(TAHUN = as.numeric(as.character(TAHUN))) %>% 
    group_by(TAHUN) %>%
    summarise(Y_Pred = mean(Y_Pred, na.rm = TRUE)) %>%
    bind_rows(data_anchor_2024) %>% 
    mutate(Skenario = name) %>%
    arrange(TAHUN)
}

# 3. Sekarang jalankan ulang pemanggilan fungsinya
avg_bau     <- get_avg_scen(scen_bau, "1. Business as Usual (BAU)")
avg_moderat <- get_avg_scen(scen_moderat, "2. Kebijakan Moderat (Konservasi X1)")
avg_agresif <- get_avg_scen(scen_agresif, "3. Kebijakan Agresif (X1 & X2)")
avg_total   <- get_avg_scen(scen_total, "4. Kebijakan TOTAL (X1, X2, X4)")

# 4. Pastikan juga data historis menggunakan numeric
avg_hist <- df_gtwr %>%
  mutate(TAHUN = as.numeric(as.character(TAHUN))) %>%
  group_by(TAHUN) %>%
  summarise(Y_Pred = mean(Y, na.rm = TRUE)) %>%
  mutate(Skenario = "Historis")

# Gabung semua untuk plot
df_final_plot <- bind_rows(avg_hist, avg_bau, avg_moderat, avg_agresif, avg_total)


ggplot(df_final_plot, aes(x = TAHUN, y = Y_Pred, color = Skenario, group = Skenario)) +
  # Garis Historis (Lebih Tebal)
  geom_line(data = filter(df_final_plot, Skenario == "Historis"), linewidth = 1.5, color = "black") +
  # Garis Skenario (Putus-putus)
  geom_line(data = filter(df_final_plot, Skenario != "Historis"), aes(linetype = Skenario), linewidth = 1.2) +
  geom_point(size = 2, alpha = 0.6) +
  # Garis pembatas tahun berjalan
  geom_vline(xintercept = 2024, linetype = "dotted", color = "grey40", linewidth = 1) +
  # Warna kustom
  scale_color_manual(values = c(
    "Historis" = "black",
    "1. Business as Usual (BAU)" = "#d73027",      # Merah
    "2. Kebijakan Moderat (Konservasi X1)" = "#fee090", # Kuning/Oranye
    "3. Kebijakan Agresif (X1 & X2)" = "#91bfdb",      # Biru Muda
    "4. Kebijakan TOTAL (X1, X2, X4)" = "#1a9850"      # Hijau
  )) +
  scale_linetype_manual(values = c(
    "Historis" = "solid",
    "1. Business as Usual (BAU)" = "dashed",
    "2. Kebijakan Moderat (Konservasi X1)" = "twodash",
    "3. Kebijakan Agresif (X1 & X2)" = "longdash",
    "4. Kebijakan TOTAL (X1, X2, X4)" = "dotdash"
  )) +
  labs(
    title = "Simulasi Dampak Intervensi Kebijakan terhadap Banjir di Sumatera",
    subtitle = "Analisis Berbasis Random Forest (Rata-rata Keseluruhan KABKOT)",
    x = "Tahun",
    y = "Rata-rata Kejadian Banjir",
    caption = "Keterangan: Intervensi dimulai secara bertahap pada periode 2025-2030"
  ) +
  theme_minimal() +
  theme(
    legend.position = "bottom",
    legend.title = element_blank(),
    legend.text = element_text(size = 9),
    plot.title = element_text(face = "bold", size = 14)
  )

# ==============================================================================
# VISUALISASI PERBANDINGAN 4 PETA SKENARIO (SATU LEGENDA)
# ==============================================================================

# 1. Persiapan Data: Gabungkan Tahun 2030 dari 4 Skenario
# Pastikan setiap skenario diberi label yang jelas
df_scen1_30 <- scen_bau      %>% filter(as.numeric(as.character(TAHUN)) == 2030) %>% mutate(LABEL = "Skenario 1: BAU")
df_scen2_30 <- scen_moderat  %>% filter(as.numeric(as.character(TAHUN)) == 2030) %>% mutate(LABEL = "Skenario 2: Moderat")
df_scen3_30 <- scen_agresif  %>% filter(as.numeric(as.character(TAHUN)) == 2030) %>% mutate(LABEL = "Skenario 3: Agresif")
df_scen4_30 <- scen_total    %>% filter(as.numeric(as.character(TAHUN)) == 2030) %>% mutate(LABEL = "Skenario 4: Total")

# Gabungkan secara vertikal
df_all_scen_2030 <- bind_rows(df_scen1_30, df_scen2_30, df_scen3_30, df_scen4_30) %>%
  mutate(KABKOT_JOIN = toupper(trimws(as.character(KABKOT))))

# 2. Join dengan Shapefile map_sumatera
map_all_scen_plot <- map_sumatera %>%
  mutate(KABKOT_JOIN = toupper(trimws(as.character(name)))) %>%
  left_join(df_all_scen_2030, by = "KABKOT_JOIN")

# Pastikan urutan panel peta logis
map_all_scen_plot$LABEL <- factor(map_all_scen_plot$LABEL, 
                                  levels = c("Skenario 1: BAU", "Skenario 2: Moderat", 
                                             "Skenario 3: Agresif", "Skenario 4: Total"))

# 3. Plotting 4 Peta (Facet Wrap)
p_4_scen_final <- ggplot(map_all_scen_plot) +
  # Gambar wilayah dengan fill berdasarkan Y_Pred
  geom_sf(aes(fill = Y_Pred), color = "black", size = 0.03) +
  
  # Membuat panel 2x2 untuk 4 skenario
  facet_wrap(~LABEL, ncol = 2) +
  
  # Skala warna tunggal (Plasma)
  scale_fill_viridis_c(
    option = "plasma", 
    name = "Prediksi\nKejadian Banjir",
    na.value = "grey95",
    guide = guide_colorbar(
      barwidth = unit(0.5, "cm"),
      barheight = unit(7, "cm")
    )
  ) +
  
  labs(
    title = "Perbandingan Spasial Risiko Banjir Sumatera Tahun 2030", 
    subtitle = "Simulasi Dampak Intervensi Kebijakan Lahan dan Kependudukan",
    caption = "S1: Tren Alami | S2: Konservasi X1 | S3: Reduksi X1 & X2 | S4: Intervensi Total Targeted\nModel: Hybrid ARIMA-Random Forest",
    x = NULL, y = NULL
  ) +
  
  # Ganti bagian theme pada kodingan sebelumnya dengan ini:
  theme_void() +
  theme(
    plot.title = element_text(size = 18, face = "bold", hjust = 0.5),
    # Gunakan ggplot2::margin untuk menghindari konflik dengan randomForest
    plot.subtitle = element_text(size = 12, hjust = 0.5, color = "grey30", 
                                 margin = ggplot2::margin(b = 10)),
    legend.position = "right",
    strip.background = element_rect(fill = "gray20"),
    strip.text = element_text(color = "white", face = "bold", size = 10, 
                              margin = ggplot2::margin(5, 5, 5, 5)),
    plot.margin = ggplot2::margin(10, 10, 10, 10),
    panel.spacing = unit(1, "lines")
  )

# Tampilkan Peta Gabungan
print(p_4_scen_final)

# Simpan dengan resolusi tinggi
# ggsave("Perbandingan_4_Skenario_Sumatera_2030.png", p_4_scen_final, width = 12, height = 15, dpi = 300)