3
$\begingroup$

I have a complex data set and I want to fit with a mathematical model using NonlinearModelFit, but an error appears. Following is the data I'm using and the code that I have tried.

 dataset = {{0.1, 78.2356 - 0.8683 I}, {0.1998, 78.4897 - 0.5794 I}, {0.2996, 
      78.1675 - 1.0737 I}, {0.3994, 78.2344 - 1.4989 I}, {0.4992, 
      78.1883 - 1.8812 I}, {0.599, 78.1934 - 2.2289 I}, {0.6988, 
      78.1711 - 2.5836 I}, {0.7986, 78.1692 - 3.0154 I}, {0.8984, 
      78.1315 - 3.3294 I}, {0.9982, 78.0316 - 3.6955 I}, {1.098, 
      78.0287 - 4.0985 I}, {1.1978, 77.9932 - 4.4796 I}, {1.2976, 
      77.9667 - 4.8723 I}, {1.3974, 77.8871 - 5.2557 I}, {1.4972, 
      77.7778 - 5.6587 I}, {1.597, 77.5958 - 5.9334 I}, {1.6968, 
      77.7181 - 6.2427 I}, {1.7966, 77.661 - 6.6707 I}, {1.8964, 
      77.6011 - 7.0251 I}, {1.9962, 77.4963 - 7.394 I}, {2.096, 
      77.4624 - 7.8034 I}, {2.1958, 77.3749 - 8.1873 I}, {2.2956, 
      77.2339 - 8.5655 I}, {2.3954, 77.1747 - 8.8844 I}, {2.4952, 
      76.9861 - 9.2161 I}, {2.595, 76.9674 - 9.4487 I}, {2.6948, 
      77.0184 - 9.9153 I}, {2.7946, 76.8488 - 10.3242 I}, {2.8944, 
      76.7229 - 10.6691 I}, {2.9942, 76.6241 - 11.0533 I}, {3.094, 
      76.4483 - 11.3778 I}, {3.1938, 76.3633 - 11.7194 I}, {3.2936, 
      76.2347 - 12.0944 I}, {3.3934, 76.117 - 12.3783 I}, {3.4932, 
      76.0038 - 12.7369 I}, {3.593, 75.897 - 13.1024 I}, {3.6928, 
      75.7642 - 13.4812 I}, {3.7926, 75.6128 - 13.8315 I}, {3.8924, 
      75.4548 - 14.1748 I}, {3.9922, 75.3121 - 14.5079 I}, {4.092, 
      75.112 - 14.846 I}, {4.1918, 74.9628 - 15.1255 I}, {4.2916, 
      74.7993 - 15.4578 I}, {4.3914, 74.6315 - 15.8132 I}, {4.4912, 
      74.4547 - 16.1097 I}, {4.591, 74.2938 - 16.4089 I}, {4.6908, 
      74.152 - 16.7319 I}, {4.7906, 73.9702 - 16.9752 I}, {4.8904, 
      73.8144 - 17.2465 I}, {4.9902, 73.6398 - 17.5256 I}, {5.09, 
      73.5109 - 17.8629 I}, {5.1898, 73.3688 - 18.1599 I}, {5.2896, 
      73.2115 - 18.4785 I}, {5.3894, 73.0502 - 18.7804 I}, {5.4892, 
      72.8459 - 19.0808 I}, {5.589, 72.6908 - 19.4046 I}, {5.6888, 
      72.5409 - 19.711 I}, {5.7886, 72.3442 - 20.0245 I}, {5.8884, 
      72.1652 - 20.2782 I}, {5.9882, 71.9966 - 20.6356 I}, {6.088, 
      71.7659 - 20.9083 I}, {6.1878, 71.5486 - 21.2 I}, {6.2876, 
      71.3843 - 21.4641 I}, {6.3874, 71.1986 - 21.7711 I}, {6.4872, 
      70.9554 - 22.0703 I}, {6.587, 70.724 - 22.3318 I}, {6.6868, 
      70.4961 - 22.6017 I}, {6.7866, 70.2746 - 22.8812 I}, {6.8864, 
      70.0688 - 23.1126 I}, {6.9862, 69.8475 - 23.4055 I}, {7.086, 
      69.6181 - 23.6201 I}, {7.1858, 69.4073 - 23.8674 I}, {7.2856, 
      69.1847 - 24.1005 I}, {7.3854, 68.9453 - 24.3616 I}, {7.4852, 
      68.7403 - 24.5436 I}, {7.585, 68.5239 - 24.8114 I}, {7.6848, 
      68.2914 - 25.0535 I}, {7.7846, 68.0972 - 25.2649 I}, {7.8844, 
      67.8553 - 25.5043 I}, {7.9842, 67.6882 - 25.7208 I}, {8.084, 
      67.4227 - 25.9499 I}, {8.1838, 67.1762 - 26.1625 I}, {8.2836, 
      66.9512 - 26.3742 I}, {8.3834, 66.7394 - 26.6041 I}, {8.4832, 
      66.5167 - 26.842 I}, {8.583, 66.3146 - 27.0334 I}, {8.6828, 
      66.0724 - 27.2423 I}, {8.7826, 65.8313 - 27.4527 I}, {8.8824, 
      65.6043 - 27.6363 I}, {8.9822, 65.3769 - 27.9247 I}, {9.082, 
      65.1264 - 28.1023 I}, {9.1818, 64.8719 - 28.2838 I}, {9.2816, 
      64.6268 - 28.4543 I}, {9.3814, 64.4335 - 28.6643 I}, {9.4812, 
      64.1462 - 28.892 I}, {9.581, 63.9215 - 29.021 I}, {9.6808, 
      63.6482 - 29.2224 I}, {9.7806, 63.4241 - 29.4026 I}, {9.8804, 
      63.2 - 29.5862 I}, {9.9802, 62.9566 - 29.749 I}, {10.08, 
      62.7357 - 29.9395 I}, {10.1798, 62.4715 - 30.1185 I}, {10.2796, 
      62.1795 - 30.2156 I}, {10.3794, 61.96 - 30.4348 I}, {10.4792, 
      61.7823 - 30.5786 I}, {10.579, 61.4458 - 30.7737 I}, {10.6788, 
      61.2525 - 30.9524 I}, {10.7786, 60.9821 - 31.029 I}, {10.8784, 
      60.7528 - 31.2795 I}, {10.9782, 60.497 - 31.3811 I}, {11.078, 
      60.2911 - 31.4382 I}, {11.1778, 60.0138 - 31.6786 I}, {11.2776, 
      59.7766 - 31.7127 I}, {11.3774, 59.5339 - 31.9257 I}, {11.4772, 
      59.3229 - 32.0314 I}, {11.577, 59.0414 - 32.1797 I}, {11.6768, 
      58.7069 - 32.3222 I}, {11.7766, 58.6335 - 32.4309 I}, {11.8764, 
      58.2855 - 32.6102 I}, {11.9762, 57.9934 - 32.5999 I}, {12.076, 
      57.8657 - 32.8212 I}, {12.1758, 57.5263 - 32.79 I}, {12.2756, 
      57.43 - 33.0486 I}, {12.3754, 56.9925 - 33.0071 I}, {12.4752, 
      56.9032 - 33.357 I}, {12.575, 56.6686 - 33.2642 I}, {12.6748, 
      56.4106 - 33.4076 I}, {12.7746, 56.1114 - 33.6666 I}, {12.8744, 
      55.9125 - 33.7541 I}, {12.9742, 55.7078 - 33.7603 I}, {13.074, 
      55.3646 - 33.919 I}, {13.1738, 55.1957 - 33.9628 I}, {13.2736, 
      54.8702 - 34.0163 I}, {13.3734, 54.6922 - 34.2249 I}, {13.4732, 
      54.4734 - 34.3232 I}, {13.573, 54.2027 - 34.3559 I}, {13.6728, 
      53.9333 - 34.4731 I}, {13.7726, 53.6691 - 34.5305 I}, {13.8724, 
      53.5039 - 34.4862 I}, {13.9722, 53.27 - 34.6338 I}, {14.072, 
      52.8795 - 34.7439 I}, {14.1718, 52.6861 - 34.7778 I}, {14.2716, 
      52.503 - 34.8645 I}, {14.3714, 52.4029 - 34.9377 I}, {14.4712, 
      52.2769 - 35.0561 I}, {14.571, 51.9974 - 35.1729 I}, {14.6708, 
      51.6274 - 35.2887 I}, {14.7706, 51.3093 - 35.3206 I}, {14.8704, 
      51.1775 - 35.2592 I}, {14.9702, 50.9441 - 35.2813 I}, {15.07, 
      50.6445 - 35.2355 I}, {15.1698, 50.387 - 35.4794 I}, {15.2696, 
      50.2707 - 35.462 I}, {15.3694, 49.9586 - 35.5747 I}, {15.4692, 
      49.6906 - 35.4405 I}, {15.569, 49.5962 - 35.6865 I}, {15.6688, 
      49.2882 - 35.7023 I}, {15.7686, 48.9925 - 35.7119 I}, {15.8684, 
      48.9255 - 35.7546 I}, {15.9682, 48.8472 - 35.9351 I}, {16.068, 
      48.4388 - 35.908 I}, {16.1678, 48.4093 - 35.9757 I}, {16.2676, 
      48.0541 - 35.8649 I}, {16.3674, 47.932 - 35.9882 I}, {16.4672, 
      47.6193 - 35.9926 I}, {16.567, 47.423 - 36.2149 I}, {16.6668, 
      47.1304 - 36.1237 I}, {16.7666, 46.8657 - 36.0961 I}, {16.8664, 
      46.8233 - 36.1513 I}, {16.9662, 46.4927 - 36.3335 I}, {17.066, 
      46.282 - 36.1248 I}, {17.1658, 46.0527 - 36.2736 I}, {17.2656, 
      45.7096 - 36.1602 I}, {17.3654, 45.6516 - 36.1769 I}, {17.4652, 
      45.5632 - 36.3304 I}, {17.565, 45.2815 - 36.3742 I}, {17.6648, 
      45.1287 - 36.4635 I}, {17.7646, 44.8639 - 36.384 I}, {17.8644, 
      44.5912 - 36.4433 I}, {17.9642, 44.3884 - 36.4687 I}, {18.064, 
      44.2389 - 36.4418 I}, {18.1638, 44.1411 - 36.5143 I}, {18.2636, 
      43.9103 - 36.559 I}, {18.3634, 43.6563 - 36.4571 I}, {18.4632, 
      43.4871 - 36.5651 I}, {18.563, 43.3273 - 36.5756 I}, {18.6628, 
      42.9873 - 36.6038 I}, {18.7626, 42.9083 - 36.5295 I}, {18.8624, 
      42.6972 - 36.3761 I}, {18.9622, 42.3707 - 36.5342 I}, {19.062, 
      42.2738 - 36.5439 I}, {19.1618, 42.0595 - 36.5423 I}, {19.2616, 
      41.9375 - 36.4932 I}, {19.3614, 41.7015 - 36.5501 I}, {19.4612, 
      41.5701 - 36.4344 I}, {19.561, 41.2793 - 36.4456 I}, {19.6608, 
      41.0975 - 36.544 I}, {19.7606, 40.9272 - 36.5619 I}, {19.8604, 
      40.8173 - 36.4263 I}, {19.9602, 40.5276 - 36.4277 I}, {20.06, 
      40.5298 - 36.3943 I}, {20.1598, 40.2316 - 36.3789 I}, {20.2596, 
      40.1209 - 36.4193 I}, {20.3594, 39.8604 - 36.5787 I}, {20.4592, 
      39.7385 - 36.4455 I}, {20.559, 39.5266 - 36.522 I}, {20.6588, 
      39.3144 - 36.4394 I}, {20.7586, 39.3321 - 36.4143 I}, {20.8584, 
      39.0912 - 36.4885 I}, {20.9582, 38.9314 - 36.2492 I}, {21.058, 
      38.5343 - 36.24 I}, {21.1578, 38.5108 - 36.3822 I}, {21.2576, 
      38.4282 - 36.3555 I}, {21.3574, 38.1504 - 36.4566 I}, {21.4572, 
      38.0167 - 36.2047 I}, {21.557, 37.7961 - 36.2409 I}, {21.6568, 
      37.5403 - 36.2281 I}, {21.7566, 37.3251 - 36.2135 I}, {21.8564, 
      37.258 - 36.1749 I}, {21.9562, 37.174 - 36.1892 I}, {22.056, 
      37.0593 - 36.2818 I}, {22.1558, 36.7329 - 36.2821 I}, {22.2556, 
      36.6355 - 36.2482 I}, {22.3554, 36.466 - 36.1053 I}, {22.4552, 
      36.281 - 36.0756 I}, {22.555, 36.2407 - 36.1418 I}, {22.6548, 
      36.0274 - 36.1273 I}, {22.7546, 35.9257 - 36.0706 I}, {22.8544, 
      35.7085 - 36.0424 I}, {22.9542, 35.487 - 35.9645 I}, {23.054, 
      35.3758 - 35.8514 I}, {23.1538, 35.24 - 35.909 I}, {23.2536, 
      35.1003 - 36.0131 I}, {23.3534, 35.0614 - 35.9159 I}, {23.4532, 
      34.9312 - 35.866 I}, {23.553, 34.429 - 35.9661 I}, {23.6528, 
      34.4772 - 35.6764 I}, {23.7526, 34.1887 - 35.7948 I}, {23.8524, 
      34.0702 - 35.7791 I}, {23.9522, 34.0382 - 35.7418 I}, {24.052, 
      33.7731 - 35.8373 I}, {24.1518, 33.7543 - 35.5773 I}, {24.2516, 
      33.6515 - 35.5328 I}, {24.3514, 33.3638 - 35.7687 I}, {24.4512, 
      33.2197 - 35.5497 I}, {24.551, 33.1856 - 35.429 I}, {24.6508, 
      32.8109 - 35.4585 I}, {24.7506, 32.8435 - 35.3567 I}, {24.8504, 
      32.6808 - 35.4156 I}, {24.9502, 32.5051 - 35.3273 I}, {25.05, 
      32.2659 - 35.1744 I}, {25.1498, 32.4265 - 35.3344 I}, {25.2496, 
      32.1252 - 35.2248 I}, {25.3494, 31.9565 - 35.2524 I}, {25.4492, 
      32.0133 - 35.1773 I}, {25.549, 31.8092 - 35.1778 I}, {25.6488, 
      32.0878 - 35.0699 I}, {25.7486, 31.5873 - 34.6076 I}, {25.8484, 
      31.2771 - 35.0794 I}, {25.9482, 31.5152 - 34.5532 I}, {26.048, 
      31.303 - 34.9144 I}, {26.1478, 30.9818 - 34.9513 I}, {26.2476, 
      30.8336 - 34.773 I}, {26.3474, 31.0272 - 34.896 I}, {26.4472, 
      30.6672 - 34.7709 I}, {26.547, 30.5985 - 34.8338 I}, {26.6468, 
      30.5358 - 34.8296 I}, {26.7466, 30.2887 - 34.7839 I}, {26.8464, 
      30.2015 - 34.5392 I}, {26.9462, 30.0512 - 34.6196 I}, {27.046, 
      29.9653 - 34.541 I}, {27.1458, 29.804 - 34.5801 I}, {27.2456, 
      29.6835 - 34.5962 I}, {27.3454, 29.6406 - 34.502 I}, {27.4452, 
      29.4564 - 34.4098 I}, {27.545, 29.3452 - 34.4996 I}, {27.6448, 
      29.1932 - 34.3772 I}, {27.7446, 29.1953 - 34.2989 I}, {27.8444, 
      29.0024 - 34.1343 I}, {27.9442, 28.8577 - 34.1517 I}, {28.044, 
      28.703 - 34.0196 I}, {28.1438, 28.6418 - 34.0946 I}, {28.2436, 
      28.58 - 34.0431 I}, {28.3434, 28.3131 - 33.9986 I}, {28.4432, 
      28.2246 - 33.9749 I}, {28.543, 28.1047 - 34.0503 I}, {28.6428, 
      28.0789 - 33.7741 I}, {28.7426, 27.8409 - 33.7681 I}, {28.8424, 
      27.8007 - 33.8519 I}, {28.9422, 27.5743 - 33.7117 I}, {29.042, 
      27.8188 - 33.6009 I}, {29.1418, 27.6161 - 33.5073 I}, {29.2416, 
      27.4297 - 33.6119 I}, {29.3414, 27.3634 - 33.5724 I}, {29.4412, 
      27.3038 - 33.5951 I}, {29.541, 27.1626 - 33.2034 I}, {29.6408, 
      27.0371 - 33.3796 I}, {29.7406, 26.8387 - 33.268 I}, {29.8404, 
      26.8122 - 33.2622 I}, {29.9402, 26.6344 - 33.2716 I}, {30.04, 
      26.6695 - 33.3534 I}, {30.1398, 26.5725 - 32.789 I}, {30.2396, 
      26.3733 - 33.226 I}, {30.3394, 26.2388 - 32.951 I}, {30.4392, 
      26.5557 - 33.177 I}, {30.539, 26.1338 - 33.0525 I}, {30.6388, 
      25.8534 - 32.933 I}, {30.7386, 26.0376 - 32.9274 I}, {30.8384, 
      26.0954 - 32.9956 I}, {30.9382, 25.7592 - 32.9014 I}, {31.038, 
      25.4958 - 32.8915 I}, {31.1378, 25.6263 - 32.6875 I}, {31.2376, 
      25.3777 - 32.7197 I}, {31.3374, 25.4505 - 32.852 I}, {31.4372, 
      25.2404 - 32.7977 I}, {31.537, 25.3987 - 32.4925 I}, {31.6368, 
      25.1363 - 32.3624 I}, {31.7366, 24.9608 - 32.3569 I}, {31.8364, 
      24.6876 - 32.5949 I}, {31.9362, 24.8773 - 32.361 I}, {32.036, 
      24.7508 - 32.3924 I}, {32.1358, 24.7399 - 32.16 I}, {32.2356, 
      24.5998 - 32.0557 I}, {32.3354, 24.5433 - 32.1212 I}, {32.4352, 
      24.3455 - 32.3712 I}, {32.535, 23.9694 - 32.0721 I}, {32.6348, 
      24.1629 - 31.8856 I}, {32.7346, 24.0315 - 32.056 I}, {32.8344, 
      23.7825 - 31.8144 I}, {32.9342, 24.0951 - 31.867 I}, {33.034, 
      23.6539 - 31.6875 I}, {33.1338, 23.7025 - 31.7136 I}, {33.2336, 
      23.5243 - 31.7632 I}, {33.3334, 23.6693 - 31.6976 I}, {33.4332, 
      23.2781 - 32.0396 I}, {33.533, 23.2774 - 31.6915 I}, {33.6328, 
      23.4158 - 31.588 I}, {33.7326, 23.2458 - 31.0499 I}, {33.8324, 
      23.385 - 31.3526 I}, {33.9322, 23.1822 - 31.9303 I}, {34.032, 
      23.0974 - 30.9541 I}, {34.1318, 22.9448 - 30.8666 I}, {34.2316, 
      22.9013 - 31.1484 I}, {34.3314, 23.2542 - 31.2115 I}, {34.4312, 
      22.397 - 31.0947 I}, {34.531, 22.9416 - 31.5076 I}, {34.6308, 
      21.9635 - 31.074 I}, {34.7306, 22.3843 - 31.0943 I}, {34.8304, 
      22.3009 - 31.1258 I}, {34.9302, 22.1042 - 31.1654 I}, {35.03, 
      22.5128 - 30.9664 I}, {35.1298, 22.339 - 31.1127 I}, {35.2296, 
      21.9851 - 30.8603 I}, {35.3294, 22.1375 - 30.9703 I}, {35.4292, 
      21.9631 - 30.7983 I}, {35.529, 22.286 - 30.9338 I}, {35.6288, 
      21.458 - 30.3835 I}, {35.7286, 21.3285 - 30.7709 I}, {35.8284, 
      21.8479 - 30.4151 I}, {35.9282, 21.6401 - 30.5023 I}, {36.028, 
      21.6042 - 30.496 I}, {36.1278, 21.461 - 30.0798 I}, {36.2276, 
      21.2528 - 29.9247 I}, {36.3274, 21.2585 - 30.5237 I}, {36.4272, 
      21.3279 - 30.3249 I}, {36.527, 21.4263 - 30.1211 I}, {36.6268, 
      21.4058 - 30.3662 I}, {36.7266, 21.1253 - 30.1514 I}, {36.8264, 
      21.2413 - 30.4202 I}, {36.9262, 21.1598 - 30.0798 I}, {37.026, 
      20.9465 - 30.0659 I}, {37.1258, 20.6829 - 30.0269 I}, {37.2256, 
      20.6885 - 29.8712 I}, {37.3254, 20.4891 - 30.1871 I}, {37.4252, 
      20.7532 - 30.1849 I}, {37.525, 20.7161 - 29.8535 I}, {37.6248, 
      20.735 - 29.5632 I}, {37.7246, 20.2155 - 29.6935 I}, {37.8244, 
      20.0769 - 29.622 I}, {37.9242, 20.4147 - 29.9926 I}, {38.024, 
      20.9966 - 29.8357 I}, {38.1238, 20.4021 - 29.9879 I}, {38.2236, 
      20.136 - 29.2182 I}, {38.3234, 20.0021 - 29.7264 I}, {38.4232, 
      20.063 - 29.5102 I}, {38.523, 19.7925 - 29.852 I}, {38.6228, 
      20.2011 - 29.744 I}, {38.7226, 19.6156 - 29.6467 I}, {38.8224, 
      19.9306 - 28.4294 I}, {38.9222, 19.3085 - 28.5398 I}, {39.022, 
      19.1026 - 29.2675 I}, {39.1218, 19.1628 - 29.3752 I}, {39.2216, 
      19.605 - 28.9693 I}, {39.3214, 19.6677 - 28.804 I}, {39.4212, 
      18.8673 - 28.5751 I}, {39.521, 18.5662 - 28.675 I}, {39.6208, 
      18.6279 - 28.8541 I}, {39.7206, 18.8227 - 28.9262 I}, {39.8204, 
      19.4427 - 28.9469 I}, {39.9202, 19.5005 - 28.3647 I}, {40.02, 
      18.4979 - 28.1689 I}, {40.1198, 18.2211 - 28.3022 I}, {40.2196, 
      18.569 - 28.2742 I}, {40.3194, 18.7859 - 28.6754 I}, {40.4192, 
      18.5712 - 28.4534 I}, {40.519, 19.3936 - 27.9846 I}, {40.6188, 
      18.4431 - 27.5675 I}, {40.7186, 18.1889 - 28.0742 I}, {40.8184, 
      18.5421 - 28.2055 I}, {40.9182, 18.6898 - 28.4374 I}, {41.018, 
      18.3297 - 28.0645 I}, {41.1178, 18.8042 - 27.8506 I}, {41.2176, 
      18.3059 - 27.344 I}, {41.3174, 18.5508 - 27.7339 I}, {41.4172, 
      17.9299 - 28.1919 I}, {41.517, 17.9836 - 27.7716 I}, {41.6168, 
      18.2556 - 27.7537 I}, {41.7166, 17.9775 - 28.0211 I}, {41.8164, 
      18.3221 - 27.786 I}, {41.9162, 17.7802 - 27.4491 I}, {42.016, 
      17.9248 - 27.6812 I}, {42.1158, 17.9283 - 27.5206 I}, {42.2156, 
      18.1385 - 27.7968 I}, {42.3154, 17.5093 - 27.5915 I}, {42.4152, 
      18.0288 - 27.3542 I}, {42.515, 17.8391 - 27.5258 I}, {42.6148, 
      18.2251 - 27.4179 I}, {42.7146, 17.4823 - 27.427 I}, {42.8144, 
      17.5969 - 27.0717 I}, {42.9142, 17.2438 - 27.2268 I}, {43.014, 
      17.5722 - 26.9162 I}, {43.1138, 17.0512 - 27.4752 I}, {43.2136, 
      17.731 - 27.7474 I}, {43.3134, 17.9637 - 27.0977 I}, {43.4132, 
      17.8519 - 26.5461 I}, {43.513, 16.4758 - 27.4136 I}, {43.6128, 
      17.5664 - 27.4024 I}, {43.7126, 17.3127 - 26.7502 I}, {43.8124, 
      17.0702 - 28.1142 I}, {43.9122, 16.944 - 25.6304 I}, {44.012, 
      17.6921 - 26.3435 I}, {44.1118, 16.7857 - 26.9177 I}, {44.2116, 
      17.8315 - 26.765 I}, {44.3114, 16.7895 - 26.8332 I}, {44.4112, 
      16.9196 - 26.2703 I}, {44.511, 16.7878 - 26.4833 I}, {44.6108, 
      16.5801 - 26.8623 I}, {44.7106, 16.9558 - 26.4815 I}, {44.8104, 
      16.7723 - 26.5304 I}, {44.9102, 16.6461 - 26.5571 I}, {45.01, 
      16.445 - 26.2377 I}, {45.1098, 16.3595 - 26.1725 I}, {45.2096, 
      16.6057 - 26.3542 I}, {45.3094, 16.8819 - 26.7169 I}, {45.4092, 
      16.7706 - 26.4544 I}, {45.509, 16.186 - 26.0565 I}, {45.6088, 
      16.5001 - 26.0794 I}, {45.7086, 16.2941 - 26.4279 I}, {45.8084, 
      16.0685 - 26.4002 I}, {45.9082, 16.5396 - 26.0268 I}, {46.008, 
      15.7409 - 26.6186 I}, {46.1078, 16.4295 - 26.1331 I}, {46.2076, 
      15.5538 - 26.457 I}, {46.3074, 16.4832 - 25.7581 I}, {46.4072, 
      15.8374 - 26.0055 I}, {46.507, 15.7819 - 26.8736 I}, {46.6068, 
      15.8253 - 25.7855 I}, {46.7066, 16.385 - 26.3928 I}, {46.8064, 
      16.2869 - 26.1208 I}, {46.9062, 15.5076 - 25.7764 I}, {47.006, 
      15.9992 - 26.1976 I}, {47.1058, 15.8232 - 25.8068 I}, {47.2056, 
      15.6416 - 25.5574 I}, {47.3054, 15.7279 - 25.4791 I}, {47.4052, 
      15.23 - 24.9536 I}, {47.505, 16.2428 - 24.9651 I}, {47.6048, 
      15.4889 - 26.3522 I}, {47.7046, 15.2959 - 24.9988 I}, {47.8044, 
      15.3342 - 25.6946 I}, {47.9042, 15.3437 - 25.544 I}, {48.004, 
      15.3685 - 25.4386 I}, {48.1038, 15.2888 - 25.6183 I}, {48.2036, 
      15.6667 - 25.3608 I}, {48.3034, 15.5084 - 24.8011 I}, {48.4032, 
      15.3141 - 25.2034 I}, {48.503, 15.0334 - 25.3849 I}, {48.6028, 
      15.3935 - 24.5825 I}, {48.7026, 15.4125 - 25.0509 I}, {48.8024, 
      14.9718 - 25.1981 I}, {48.9022, 14.7825 - 25.0575 I}, {49.002, 
      15.2234 - 25.1159 I}, {49.1018, 14.9325 - 25.1141 I}, {49.2016, 
      14.9938 - 25.3016 I}, {49.3014, 14.9617 - 24.3614 I}, {49.4012, 
      14.8526 - 25.004 I}, {49.501, 14.8749 - 24.9538 I}, {49.6008, 
      15.208 - 24.7995 I}, {49.7006, 14.6468 - 25.1923 I}, {49.8004, 
      14.7013 - 24.5138 I}, {49.9002, 15.0272 - 24.3538 I}, {50., 
      14.9279 - 24.6538 I}};

Here is the the code:

Subscript[ϵ, 0] = 8.854*10^-12
modelfit = 
  NonlinearModelFit[dataset, 
    Subscript[ϵ, ∞] + (Subscript[ϵ, 1] - 
    Subscript[ϵ, ∞])/(
    1 + I*2*π*f*Subscript[τ, 1]) + σ/(
    I*2*π*f*Subscript[ϵ, 0]), {{Subscript[ϵ, 1],
    78.88}, {Subscript[ϵ, ∞], 
    5.2}, {Subscript[τ, 1], 0.008}, {σ, 0.2}}, f];

This error appears:

NonlinearModelFit::nrlnum: The function value {0.642538 -3.5951*10^10 I,0.382869
-1.79935*10^10 I,0.695794 -1.19997*10^10 I,<<45>>,0.867068 -7.35134*10^8 
I,0.878805 -7.20431*10^8 I,<<451>>} is not a list of real numbers with dimensions 
{501} at {Subscript[ϵ, 1],Subscript[ϵ, ∞],Subscript[τ, 1],σ} = {78.88,5.2,0.008,0.2}.

Can anyone please help me to get rid of this? Thank you.

$\endgroup$
4
  • $\begingroup$ Please have a look at 31070. $\endgroup$ Commented Jan 2, 2021 at 10:07
  • 1
    $\begingroup$ @b.gates it seems to me that in that question the results were supposed to be real, but complex values were incorrectly encountered. In the present case, however the data to fit is complex-valued, so it is no mistake that the model returns complex values for real input. $\endgroup$
    – MarcoB
    Commented Jan 2, 2021 at 15:06
  • 1
    $\begingroup$ @MarcoB Yes, thanks for checking, posted the wrong link; I meant this. $\endgroup$ Commented Jan 2, 2021 at 15:56
  • $\begingroup$ If you desire to have identical parameters for both the real and imaginary parts, you should consider mathematica.stackexchange.com/questions/866/…. $\endgroup$
    – JimB
    Commented Jan 2, 2021 at 19:44

2 Answers 2

6
$\begingroup$

Can you use model fitting that is done separately for the real and imaginary parts?

Example is given below.

Separate fitting of real and imaginary parts

Fit for the real parts:

e0 = 8.854*10^-12;
modelfitRe = NonlinearModelFit[Re /@ dataset, Re[eInf + (e1 - eInf)/(1 + I*2*\[Pi]*f*t1) + \[Sigma]/(I*2*\[Pi]*f*e0)], {{e1, 78.88}, {eInf, 5.2}, {t1, 0.008}, {\[Sigma], 0.2}},f]

enter image description here

Fit for the imaginary parts:

modelfitIm = NonlinearModelFit[Map[{#[[1]], Im[#[[2]]]} &, dataset], Im[eInf + (e1 - eInf)/(1 + I*2*\[Pi]*f*t1) + \[Sigma]/(I*2*\[Pi]*f*e0)], {{e1, 78.88}, {eInf, 5.2}, {t1, 0.008}, {\[Sigma], 0.2}},f]

NonlinearModelFit::sszero: The step size in the search has become less than the tolerance prescribed by the PrecisionGoal option, but the gradient is larger than the tolerance specified by the AccuracyGoal option. There is a possibility that the method has stalled at a point that is not a local minimum.

enter image description here

Make the complex numbers list of fits:

datasetFit = Map[{#, modelfitRe[#] + I*modelfitIm[#]} &, dataset[[All, 1]]];

See the errors for the real parts:

{ResourceFunction["RecordsSummary"][Abs[dataset[[All, 2]] - datasetFit[[All, 2]]]], ResourceFunction["RecordsSummary"][Abs[dataset[[All, 2]] - datasetFit[[All, 2]]]/Abs[dataset[[All, 2]]]]}

enter image description here

See the errors for the imaginary parts:

{ResourceFunction["RecordsSummary"][Abs[Im[dataset[[All, 2]] - datasetFit[[All, 2]]]]], ResourceFunction["RecordsSummary"][Abs[Im[dataset[[All, 2]] - datasetFit[[All, 2]]]/Im[dataset[[All, 2]]]]]}

enter image description here

Plot the original data and the fits:

gr1 = MapThread[
    ListPlot[#, PlotRange -> All, PlotTheme -> "Detailed", PlotLegends -> {"Original"}, PlotStyle -> {{PointSize[0.015], GrayLevel[0.7]}}, PlotLabel -> #2, ImageSize -> Large] &, {{Map[{#[[1]], Re[#[[2]]]} &, dataset], Map[{#[[1]], Im[#[[2]]]} &, dataset]}, {"Real parts", "Imaginary parts"}}];
gr2 = ListLinePlot[#, PlotRange -> All, PlotTheme -> "Detailed", PlotLegends -> {"Fit"}, PlotStyle -> {Red}, PlotLabel -> "Imaginary parts", ImageSize -> Large] & /@ {Map[{#[[1]], Re[#[[2]]]} &, datasetFit], Map[{#[[1]], Im[#[[2]]]} &, datasetFit]};
MapThread[Show, {gr1, gr2}]

enter image description here

$\endgroup$
4
$\begingroup$

I suspect that you need to have the same values of the parameters for both the real and imaginary parts. If the variances associated with the real and imaginary regressions are the same and the random errors are independent, then consider using MultiNonlinearModelFit.

If the variances are not known to be equal or the random errors are not independent, then consider the following. (Note that the above link the method to follow also assume that the errors have a constant variance which does not depend on among other things the predictor variable. More of that after looking at the residuals.)

The prediction equation can be separated into the real and imaginary parts (using @AntonAntonov 's notation)

eInf + (ϵ1 - eInf)/(1 + I 2 π f t1) + σ/(I 2 π f e0)// ComplexExpand

Equation split into real and imaginary parts

(* Create response and predicted matrices *)
response = Transpose[{Re[dataset[[All, 2]]], Im[dataset[[All, 2]]]}];
predicted = Transpose[{eInf + (e1 - eInf)/(1 + 4 dataset[[All, 1]]^2  π^2  t1^2),
    -(σ0/(2 dataset[[All, 1]] π)) + (2 (-e1 + eInf) dataset[[All, 1]] π t1)/(1 + 4 dataset[[All, 1]]^2 π^2 t1^2)}];

(* Log of the likelihood *)
logL = LogLikelihood[BinormalDistribution[{0, 0}, {σ1, σ2}, ρ], response - predicted];

(* Find maximum likelihood estimates *)
mle = FindMaximum[{logL, σ1 > 0 && σ2 > 0 && e1 > 0 && eInf > 0 && -1 < ρ < 1},
  {{e1, 78}, {eInf, 5}, {t1, 0.008}, {σ0, 0.1}, {σ1, 0.2}, {σ2, 0.2}, {ρ, 0}}]
(* {213.616, {e1 -> 78.2692, eInf -> 5.2173, t1 -> 0.00822744, σ0 -> 0.107965, 
  σ1 -> 0.185984, σ2 -> 0.205559, ρ -> 0.0164636}} *)

(* Get approximate 95% confidence intervals for the parameter estimates *)
covMat = -Inverse[(D[logL, {{e1, eInf, t1, σ0, σ1, σ2, ρ}, 2}]) /. mle[[2]]];
se = Sqrt[Diagonal[covMat]];
estimates = {e1, eInf, t1, σ0, σ1, σ2, ρ} /. mle[[2]];
lower95CL = ({e1, eInf, t1, σ0, σ1, σ2, ρ} /. mle[[2]]) - 1.96 se;
upper95CL = ({e1, eInf, t1, σ0, σ1, σ2, ρ} /. mle[[2]]) + 1.96 se;
TableForm[Transpose[{estimates, lower95CL, upper95CL}],
 TableHeadings -> {{"e1", "eInf", "t1", "σ0", "σ1", "σ2", "ρ"},
   {"Estimate", "Lower 95% CL", "Upper 95% CL"}}]

Regression parameter estimates and confidence intervals

Now look at the residuals.

predresid = Join[Transpose[predicted], Transpose[response - predicted]] /. mle[[2]] // Transpose;
ListPlot[Transpose[{dataset[[All, 1]], predresid[[All, 3]]}], PlotStyle -> PointSize[0.01],
  AxesLabel -> (Style[#, Bold, 12] &) /@ {"f", "Residual"}, 
 PlotLabel -> Style["Real", 18, Bold], PlotRange -> All]
ListPlot[Transpose[{dataset[[All, 1]], predresid[[All, 4]]}], 
 PlotStyle -> PointSize[0.01],
 AxesLabel -> (Style[#, Bold, 12] &) /@ {"f", "Residual"}, 
 PlotLabel -> Style["Imaginary", 18, Bold], PlotRange -> All]

Residuals vs f for the real part

Residuals vs f for the imaginary part

We see that the residuals are not constant with respect to the predictor variable $f$. If the residuals are small compared to the desired precision, then there's nothing to do. If the residuals are large compared to the desired precision, then one should also attempt to model the structure of the error variances. The actual estimates of the parameters likely won't change much but the associated standard errors and confidence intervals might depend strongly on adequately modeling the error structure.

$\endgroup$
5
  • $\begingroup$ Thank you all for the code. It really helps. $\endgroup$
    – S.Pyne
    Commented Jan 3, 2021 at 8:31
  • $\begingroup$ @JimB This code works fine to findout the parameters, but to get accurate result (to get rid of the error: modelfitIm = NonlinearModelFit[Map[{#[[1]], Im[#[[2]]]} &, dataset], Im[eInf + (e1 - eInf)/(1 + I*2*[Pi]*ft1) + [Sigma]/(I*2*[Pi]*fe0)], {{e1, 78.88}, {eInf, 5.2}, {t1, 0.008}, {[Sigma], 0.2}},f]) the gues value should be close to the actual value. but how to set that close guess value? $\endgroup$
    – P Pyne
    Commented Jan 3, 2021 at 13:29
  • $\begingroup$ Using the code modelfitIm = NonlinearModelFit[Map[{#[[1]], Im[#[[2]]]} &, dataset], Im[eInf + (e1 - eInf)/(1 + I*2*\[Pi]*f t1) + \[Sigma]/(I*2*\[Pi]*f e0)], {{e1, 78.88}, {eInf, 5.2}, {t1, 0.008}, {\[Sigma], 0.2}}, f] gets the following results: {e1 -> -22383.8, eInf -> -22456.8, t1 -> 0.00822242, \[Sigma] -> 1.14458*10^-12}. This is not about bad initial values. Just using the imaginary part results in the estimators of e1 and eInf being perfectly correlated with each other. Predictions are fine but it requires information from the real part to estimate those parameters. $\endgroup$
    – JimB
    Commented Jan 3, 2021 at 17:27
  • $\begingroup$ One can see this perfect correlation using modelfitIm["CorrelationMatrix"] // MatrixForm resulting in $\left( \begin{array}{cccc} 1. & -1. & 0.353315 & -0.131454 \\ -1. & 1. & -0.353315 & 0.131454 \\ 0.353315 & -0.353315 & 1. & -0.102679 \\ -0.131454 & 0.131454 & -0.102679 & 1. \\ \end{array} \right)$. $\endgroup$
    – JimB
    Commented Jan 3, 2021 at 17:28
  • $\begingroup$ Actually there's a more convincing and direct reason why e1 and eInf can't be estimated separately with just the imaginary part: e1 and eInf always occur together as e1 - eInf. So just the difference can be estimated. You'll still get the same predictions whether one uses a single parameter (say e1MinuseInf) or use both. $\endgroup$
    – JimB
    Commented Jan 3, 2021 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.