Question: Fix The Fortran Code Below: program resampking implicit none integer, parameter :: ns = 1 0 0 0 0 real, dimension ( 4 ) ::
Fix The Fortran Code Below:
program resampking
implicit none
integer, parameter :: ns
real, dimension :: WC
real, dimension :: WCex
integer :: i ngerandom, ngebootstrap
real :: mediangroup mediangroup teststatistic, pvaluerandom, pvaluebootstrap
real :: combined tempmedian tempmedian pseudostat
real, dimensionns :: pseudo
real :: actualstat, pvalue, corr
integer :: nge, nsize
real, dimension: allocatable :: x y xactual
real, dimension :: alpha
characterlen :: ans
combined WC WCex Correct concatenation with
call calculatestatisticsWC WCex, mediangroup mediangroup teststatistic
ngerandom
ngebootstrap
do i ns
call randompermutationcombined
call calculatestatisticscombined: combined: tempmedian tempmedian pseudostat
if abspseudostat absteststatistic then
ngerandom ngerandom
end if
tempmedian bootstrapresampleWC
tempmedian bootstrapresampleWCex
pseudostat tempmedian tempmedian
if abspseudostat absteststatistic then
ngebootstrap ngebootstrap
end if
end do
pvaluerandom realngerandom realns
pvaluebootstrap realngebootstrap realns
nsize sizeWC
call AllocateArraysnsize
x xactual
actualstat corrnsize WC WC Pass WC as both x and y
nge
do i ns
call simpleshufflensize WC
pseudoicorrnsize WC WC Pass WC as both x and y
if pseudoi actualstat nge nge
end do
pvalue realnge realns
write nge, pvalue
format Number of resampled test statistics r I &
pvalue F
write 'Level of Significance', 'Null hypothesis rejected? Yes or No
format AX A
do i
if pvalue alphai then
ans 'Yes'
else
ans No
end if
write alphai ans
format FX A
end do
Deallocate arrays
call DeallocateArrays
contains
subroutine calculatestatisticsgroup group median median teststat
real, dimension: intentin :: group group
real, intentout :: median median teststat
median mediangroup
median mediangroup
teststat median median
end subroutine calculatestatistics
subroutine randompermutationarr
real, dimension: intentinout :: arr
integer :: i j n
real :: temp
n sizearr
do i n
call randomnumbertemp
j i inttemp n i
temp arri
arri arrj
arrj temp
end do
end subroutine randompermutation
subroutine simpleshufflem y
implicit none
integer, intentin :: m
real, intentinout :: ym
real :: temp, r
integer :: j k
do j m
call randomnumberr
k j intr m j
temp yk
yk yj
yj temp
end do
end subroutine simpleshuffle
real function bootstrapresampledata
real, dimension: intentin :: data
real, dimensionsizedata :: sample
integer :: i
real :: temp
do i sizedata
call randomnumbertemp
samplei datainttemp sizedata
end do
bootstrapresample mediansample
end function bootstrapresample
real function medianarr
real, dimension: intentin :: arr
real, dimensionsizearr :: sortedarr
integer :: n
sortedarr arr
call quicksortsortedarr, sizearr Assuming quicksort is a sorting subroutine or function
n sizearr
if modn then
median sortedarrn sortedarrn
else
median sortedarrn
end if
end function median
subroutine AllocateArraysn
integer, intentin :: n
allocatexn yn xactualn
end subroutine AllocateArrays
subroutine DeallocateArrays
deallocatex y xactual
end subroutine DeallocateArrays
end program resampking
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
